vue-component

Post Form empty data

与世无争的帅哥 提交于 2020-01-06 08:43:12
问题 for me NuxtJS application i've got multiple components thats come together in one form. Here the code: AppButton.vue <template> <button class="button" :class="btnStyle" :disabled="disabled" v-bind="$attrs" v-on="$listeners"><slot /></button> </template> <script> export default { name: 'AppButton', props: { btnStyle: { type: String, default: '' }, disabled: { type: String } } } </script> AppFormInput.vue <template> <div class="form-input"> <input v-bind="$attrs" :name="name" :value="value"

how to make a div draggable in vue js?

做~自己de王妃 提交于 2020-01-06 08:29:19
问题 I have a div inside a vue component, I want to make the component draggable. I checked with many vue draggable plugins, but they have a seperate component for drag and not as a directive to just add like in angular draggable. Please help me with this? 回答1: You need to add vuedraggable to your node modules. yarn add vuedraggable and then: import draggable from 'vuedraggable' ... export default { components: { draggable, } and then you need something like this: <draggable> <div v-for=...> </div

Vue.js Show most recent unique entries

◇◆丶佛笑我妖孽 提交于 2020-01-06 08:02:12
问题 I have run into a bit of a snag. @StephenThomas graciously helped me with this issue: Vue.js only show objects with a unique property but I need to tweak it a bit more. I am creating a leaderboard for a game. I am using Firestore and I have a collection titled "leaderboard" that keeps all the teams scores. The teams have a start time. Next every time an entry is made for that team the difference in time from the start to now is put in a property titled "diff". In addition, all entries are

How can I upload file using vuex store on the vue component?

时光怂恿深爱的人放手 提交于 2020-01-06 06:03:48
问题 If I using ajax in vue component like this : It works. I successfully get the file But here I want to using vuex store My pattern of vuex store like this : I change my vue component like this : <template> <div> ... </div> </template> <script> export default { methods: { submitForm() { ... formData.append('file', files) this.updateProfile({formData, reload: true}) } } } </script> In the component vue, it will call updateProfile method in modules user The modules user like this : import { set }

Error instantiating a viukit icon

让人想犯罪 __ 提交于 2020-01-06 06:00:13
问题 Given: import Vue from 'vue' import Vuikit from 'vuikit' import VuikitIcons from '@vuikit/icons' Vue.use(Vuikit) Vue.use(VuikitIcons) ... Trying to instantiate an icon like this doesn't work: <vk-icon icon="cog" v-on:click="onClick"></vk-icon> // doesn't work error: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. I'm only able to instantiate it like this: <vk-icons-cog v-on:click.native="onClick"> // does

2 identical file, how to build a template / component in Vue.js 2

人走茶凉 提交于 2020-01-06 05:31:09
问题 I am using Vue.js 2.0 , and I have this exact same code in 2 differents files, the only thing that changes is the ID_SPECIFIC_TO_THIS_BLOCK so I am a beginner about Vue and I was wondering if there was an way to implement a kind of template that I would be able to reuse for my 2 files You can find bellow the entire code for one file: <template> <div> <div class="container"> <hp-row> <hp-column> <component v-for="component in content.column" :data="component" :key="component.id" :is=

How to add dynamic/async/lazy components in VueJs

*爱你&永不变心* 提交于 2020-01-06 05:23:18
问题 I want to add child components in parent components on the fly based on some conditions. I have come up with following pseudo-code If currentView == 'a' load component A1 load component A2 ElseIf currentView == 'b' load component B2 load component B3 I know we can register all components in parent component like: Vue.component('a1-component', require('./A1Component.vue')); Vue.component('a2-component', require('./A2Component.vue')); But I have a lot of such child components and I need to load

How to save reference to “this” in Vue component?

我是研究僧i 提交于 2020-01-06 02:41:08
问题 I'm not sure if I'm doing this properly. Please have a look at this simple Vue component Test.vue : <template> <div> Hi from {{name}} </div> </template> <script> let self; export default { created: function () { self = this; }, methods: { load() { ajax().then((obj) => self.name = obj.data); } }, data() { return { name: 'one', } } } </script> As you can see I'm saving the reference of this into a variable called self because the value of this changes in lambda functions , e.g. ajax().then((obj

How to retrieve the old and new values of a store state

回眸只為那壹抹淺笑 提交于 2020-01-05 05:28:09
问题 In my component I am trying to get the old value and new value of a particular array of objects that is assigned in the vuex store state as followed. However when I newArray and oldArray return the same array of objects. I understand from the documentation the following but I dont understand what is the best way to retrieve the different versions. Note: when mutating (rather than replacing) an Object or an Array, the old value will be the same as new value because they reference the same

How to use Vue slot-scope with nested components

喜你入骨 提交于 2020-01-05 02:32:46
问题 I am struggling to know where to use the slot-scope attribute and make sense of the documentation. Here's a simplified version of what I need to do. You can see it running here: https://jsfiddle.net/4j4zsy0g/ main code - simply use the repeater component with content to be repeated <repeater :ids="['a','b','c']"> <h3>My Title</h3> <another-component/> </repeater> repeater component <script id="repeater" type="text/x-template"> <div class="repeater"> <repeater-item v-for="id in ids" :key="id">