vue-component

Using jQuery plugin in Vue.js single file component

独自空忆成欢 提交于 2019-12-11 06:08:22
问题 I am trying to use this jQuery plugin in my Vue.js single file component. as required in the linked autocomplete plugin I imported references in index.html , for them to be available all other vue components where I need to use autocomplete feature in input field . <script src="//code.jquery.com/jquery-1.12.4.js"></script> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script> But when I

Can I dynamically create / destroy Vue components?

喜你入骨 提交于 2019-12-11 06:05:28
问题 So, I'm creating a fairly complex Vue application that fetches data from our backend API and displays it on the front-end, depending on filters the person selects. Its default is to display everything at once, then once the user selects filters, it will pull out the "card" components that don't have those attributes. Everything has been going great until today, which I tried to add Google Maps into it, via their API (I'm using the vue2-google-maps package to make this easier on myself, since

Looping through data array properties in VueJS

断了今生、忘了曾经 提交于 2019-12-11 05:57:07
问题 In vuejs you can do list rendering in the template like <td v-for="item in items"></td>...... But can you iterate over that same data array property like.... for(var i = 0; i < this.items.length; i++) this.$data.items[i] 回答1: yes Just don't worry about the this.$data.items , instead this.items , although it would also work ... 回答2: this post is quite old, but this can be useful to anyone who wants to iterate into an array of object. Instead of: for(var i =0; i < this.items.length; i++) {

Computed property on child component props

心已入冬 提交于 2019-12-11 05:54:13
问题 I'm having this setup where I have child component props that have datetime format inside it and I want to change it to more human readable format in my table, so i use moment js to change the format and to do those kinds of task it will be made more sense if I use computed property. Like this in my index.vue <div class="page-container"> <div class="page-content"> <div class="content-wrapper"> <data-viewer :source="source" :thead="thead"> <template scope="props"> <tr> <td>{{props.item.name}}<

How do I use data from Vue.js child component within parent component?

你说的曾经没有我的故事 提交于 2019-12-11 05:52:40
问题 I have a form component where I use a child component. I want to use data from the child component within the parent. My component in html: <candidates-form endpoint='/candidates/create' buttontext='Add Candidate'></candidates-form> Then here is the Vue instance: CandidatesForm.vue <template> <div class='row'> <div class='form-group'> <label>Name:</label> <input type='text' class='form-control' v-model='name'> </div> <div class='form-group'> <location-input></location-input> </div> <button

Vue Components and AJAX loaded HTML content

徘徊边缘 提交于 2019-12-11 05:49:15
问题 I have A Vue component which is basically a shorthand for complex HTML markup. On initial load, Everything works fine. I am using AJAX to load more of these components onto the page, The problem is that this component, after being loaded with AJAX, doesn't want to get compiled into HTML I only get the un-rendered Vue component like below: <component><slot>content</slot></component> I have looked at Vue.compile() and the render function but cannot figure out how to get this working or how to

How to force VueJS custom component to re-render itself and all its child component

杀马特。学长 韩版系。学妹 提交于 2019-12-11 05:48:32
问题 I have a use case where I have a custom Vue Component that populates its child components dynamically using the JSON. When this top level vue component is created it loads all the children components using the JSON. I have a provision where I can add additional controls on the form when I update the JSON from which it renders itself. So when I update the JSON on backend using AJAX, I would like re-render everything upon successful post. Also I came across few articles that say that the

How can I call a method after the loops(more than 1 loop) complete on vue js?

梦想的初衷 提交于 2019-12-11 05:47:16
问题 My vue component like this : <template> <div class="row"> <div class="col-md-3" v-for="item1 in items1"> ... </div> <div class="col-md-3" v-for="item2 in items2"> ... </div> <div class="col-md-3" v-for="item3 in items3"> ... </div> </div> </template> <script> export default { ... computed: { items1() { const n = ... // this is object return n }, items2() { const n = ... // this is object return n }, items3() { const n = ... // this is object return n } }, ... } </script> If the three loop

How to use external JavaScript objects in Vue.js methods

。_饼干妹妹 提交于 2019-12-11 05:35:15
问题 I'm trying to get Stripe working with my Vue.js 2 application. For PCI-DSS reasons, Stripe requires that their Javascript is always loaded from js.stripe.com. I've followed the instructions in: How to add external JS scripts to VueJS Components How to include a CDN to VueJS CLI without NPM or Webpack? but I get a 'Stripe' is not defined error when I try to use the library. These solutions seemed to be aimed at merely getting a <script> tag into the output HTML (e.g. for analytics), not

How should I control the state of a class instance property with a Vue component?

末鹿安然 提交于 2019-12-11 05:34:38
问题 I'm using a third-party library that uses class instances with getter/setter properties, and I'd like to control those properties using a VueJS component. I'm not supposed to use the instance as component state directly (Evan You says it's "a rabbit hole"), but if I have to write my own go-between code to map component state to class state, what's the point of reactive data binding in the first place? Example: // Toggle.js var Toggle = Vue.component("Toggle", { template: '<label><input type=