vue-component

How to use a Vue.js Plugin inside a custom Component?

偶尔善良 提交于 2019-12-04 12:13:29
问题 I need to output a table and it's content which can be updated via Ajax. So I'm planning to use vue-tables-2 (https://github.com/matfish2/vue-tables-2) which is a Vue.js plugin. Using the Laravel way, I'm writing a Vue.js custom component, so how can I use the vue-tables-2 plugin inside my component? Here an example of how to use the plugin https://jsfiddle.net/matfish2/jfa5t4sm/ . Unfortunately in the example is not wrapping the plugin inside a component. 回答1: You have two ways available to

vue.js vue-chartjs chart not updating when chartData replaced, updated etc

跟風遠走 提交于 2019-12-04 11:58:27
I am attempting to make a vue with vue-chartjs. I have followed all the associated documentation with regards to re-rendering the chart when the chartData prop is updated. My chart will only update after i resize the browser window. my parenttestchart.vue file: <template> <div> <h1>Chart datacollection update test</h1> <p>This component demonstrates fetching data from the server.</p> <p v-if="!datacollection"><em>Loading...</em></p> <b-form-select v-model="testthingSelect.selected" text="Select testthing" variant="primary" :options="testthingSelect.options" :on-change="changetestthing" class=

How to pass a javascript object to component in VueJS?

痞子三分冷 提交于 2019-12-04 09:35:41
The question may sound basic, but I am unable to figure out how to do it in VueJS I have the following in html <script> var config = {'cols':4,'color':'red'} </script> <div id="app"> <mycomponent :config="config"></mycomponent> </div> var app = new Vue({ el: '#app', data: { // config: config // I do not want to pass this } }) Following is the use case: I know this isn't working because config variable in the component is looking for app.config I do not want to pass it as data{ config:config } in the Vue Object. I can pass it as <mycomponent :config="{'cols':4,'color':'red'}"></mycomponent> but

Vue @click.native not working?

大城市里の小女人 提交于 2019-12-04 09:06:12
I have navigation component like this: <template> <nav class="navbar navbar-default navbar-fixed-top"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="">Website Builder</a> </div> <div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav"> <li> <a href="#" @click.native="currentView='create'">Create</a> </li> <li> <a href="#" @click.native="currentView='how'">How</a

Get element height with Vuejs

两盒软妹~` 提交于 2019-12-04 08:23:22
问题 I want to get the height of a div in order to make the height of another div matching it. I used the method clientHeight, but It doesn't return me the good value (smaller value). Actually, It seems to return a height before all elements are charged. After some research online, I tried to put a window.load() to delay until everything is charged but it doesn't work as well. Some ideas ? mounted () { this.matchHeight() }, matchHeight () { let height = document.getElementById('info-box')

VueJS accessing externaly imported method in vue component

柔情痞子 提交于 2019-12-04 08:21:41
I have an External Java Script File something.js function myFun(){ document.getElementById("demo").innerHTML="Hello World!"; } export default myFun; and this is my vue component Dashboard.vue <template> <div> <button type="button" name="button" @click="">Call External JS</button> <div id="demo"></div> </div> </template> <script> import something from "./something.js" export default { created(){ } } </script> I have two questions. First how do I call this method inside the created life cycle hook to automatically run. Second how do I call this method by hitting the button "Call External JS" Of

v-model for child component and v-model inside child component Vue

ぐ巨炮叔叔 提交于 2019-12-04 07:26:26
Is there a way to simplify this code? The button should also change the localValue of the child. Vue.component('my-input', { template: ` <div> <b>My Input:</b> <br> localValue: {{ localValue }} <br> <input v-model="localValue"> </div> `, props: ['value'], data() { return { localValue: this.value } }, watch: { value () { this.localValue = this.value }, localValue () { this.$emit('input', this.localValue) } } }) new Vue({ el: '#app', data: () => ({ parentValue: 'Inital value' }), methods: { change () { this.parentValue = 'Changed value' } } }) <script src="https://cdnjs.cloudflare.com/ajax/libs

Vue debounce a method?

柔情痞子 提交于 2019-12-04 06:20:38
I know Vue.js has functionality built in to debounce on an input field. I have created a slider that fires a method that does not use an input field though, and I was wondering if I can take advantage of the debounce functionality inside of a method. Is it even possible to use this functionality outside of simply adding a debounce to an input? Or do I need to write my own functionality for this? I've just tried doing something like this but it does not seem to work: this.$options.filters.debounce(this.search(), 2000); For anyone who is wondering on how to do this. I fixed this by using an

“Unknown custom element” warning inside a component tag, but not outside of it

为君一笑 提交于 2019-12-04 06:19:09
I have created a component like this: <template> <span class="my-icon"> <img :src="iSrc" :alt="iname"/> </span> </template> <script> export default { props: ['iname'], computed: { iSrc() { return require('../../../assets/images/' + this.iname + '.png') } } } </script> Using it inside a page like this: <template> <div> <h3>Share it:</h3> <social-sharing inline-template network-tag="a"> <div class="my-icons"> <network network="facebook" class="fb-icon"> <icon name="fb" /> </network> </div> </social-sharing> </div> </template> <script> import Icon from '~/comps/icon.vue' export default {

Passing data between child components

丶灬走出姿态 提交于 2019-12-04 05:59:36
I am struggling for this to work. I need to access the selected value in the ChooseLangComponent from the FormComponent. Is there any direct way to do this or we have to pass it from the parent component (act like middle man)? I already tried with $emit on ChooseLangComponent and v-on:.. on FormComponent but didn't work. ChooseLangComponent: <template lang="html"> <div class="choose-lang"> <select v-model="selected"> <option v-for="lang in langs" v-bind:value="lang.value">{{lang.text}}</option> </select> </div> </template> <script> export default { data() { return { selected: 'en', langs: [ {