vue-component

How to include external js inside vue component

我的未来我决定 提交于 2019-12-07 15:48:34
问题 I want to make a slide image in my app using jQuery Slide Image I get from internet. This source must include external JS and CSS . I just want to use this external library only for certain components, so I just want to import it in only one particular component ( Home Component ). My app uses webpack as a module bundler. How do I import external js file? I have tried doing it inside <script> in Vue Components like var slide = require('assets/template/js/jssor.slider-26.1.5.min.js'); But I

How to use a VueJS .vue component in a HTML page without a WebPack build process?

蹲街弑〆低调 提交于 2019-12-07 14:44:04
问题 I am creating a page for a legacy server rendered project. On one of its page I need to add some "dynamic". Then i import the vuejs CDN script and created a inline vue object var v = new Vue(... But there is a .vue component that I like very much and I would like to add it to the page. But it seems that this component can only be added by a WebPack import and build process. How can I use this component in my html page without WebPack build process? Is that possible? 回答1: You can use poi as

Vue props data not updating in child component

…衆ロ難τιáo~ 提交于 2019-12-07 12:12:26
问题 Hi everyone I just want some explanation about vue props data. So I'm passing value from parent component to child component. The thing is when parent data has data changes/update it's not updating in child component. Vue.component('child-component', { template: '<div class="child">{{val}}</div>', props: ['testData'], data: function () { return { val: this.testData } } }); But using the props name {{testdata}} it's displaying the data from parent properly Vue.component('child-component', {

Vue watch[fat arrow scope] providing wrong this context

99封情书 提交于 2019-12-07 11:55:25
问题 I am using lodash to debounce a function call but I am wondering why my this value is not inheriting the scope like I expect. These are are the relevant parts of my Vue component. import debounce from 'lodash/debounce'; watch: { query: debounce(() => { this.autocomplete(); }, 200, { leading: false, trailing: true }), The above case does not work because my this value does not point to the Vue component but rather shows an Object like this: Object __esModule: true default: Object __proto:

vee-validate error object - _vm.errors is undefined

China☆狼群 提交于 2019-12-07 08:55:34
问题 This is my .vue component file in which I wasn't to use Vue.use() to install vee-validate validation package. The module, as mentioned in the docs, will inject an errors object to the data object. But I do get the error _vm.errors is undefined . I'm not sure if I'm instantiating it properly. Also, will import Vue from 'Vue' and Vue.use(VeeValidate) "use" vee-validate for only this component?(which is what I want it to do). <template> <input class="form-control" name="name" placeholder="Name"

Vue: What is the cleanest way to select a component via CSS?

落花浮王杯 提交于 2019-12-07 08:30:27
问题 I have a bar component. It is used like this: <template> <div> <!-- stuff --> <bar></bar> <!-- stuff --> <!-- stuff --> <!-- stuff --> <bar></bar> <!-- stuff --> <bar></bar> <!-- stuff --> </div> </template> <style lang="scss" scoped> @media (max-width: 1300px) { // this selector doesn't work, but it would be nice if it did bar { display: none; } } </style> I would like to hide the bar elements when the screen is 1300px or narrower. It would be nice if there was a bar element selector, just

Vuejs2 update Vue.prototype global object

*爱你&永不变心* 提交于 2019-12-07 03:59:26
I have create a global object in my main.js to access logged in user's data throughout the application between controllers main.js Vue.prototype.user = getUser() // assume a method to getUser data Now the above .user object will be available in other components with this.user , what I'm looking for is if I make change to this.user in any component, the changes reflects to other components too, this is not happening right now I've two components, one to update data in this.user EditProfileComponent.vue <input type="text" v-model="user.firstName" /> <input type="text" v-model="user.lastName" />

Working hours selection?

懵懂的女人 提交于 2019-12-07 03:26:48
问题 A reference to another question saw in the stack overflow. I checked for a solution like this but haven't succeeded yet. <div class="form-group"> <label>Working Hours :</label> <div v-for="value in day" class="checkboxFour"<input type="checkbox" id="need" value="value.val" v-model="value.selected" style="width: 10%!important;"> <p>FROM</p> <label for="need" style=" width: 20%!important;">{{value.name}}</label> <input id="value.from" type="time" v-model="value.from" name="value.from" style=

Error in Unit Test VueJS component with Vuex

。_饼干妹妹 提交于 2019-12-07 03:25:04
问题 Error: undefined is not a constructor (evaluating 'vm.$el.querySelector('h3')') Follow my code and full code here // main.js import Vue from 'vue' import App from './App' import router from './router' import store from './store' import 'babel-polyfill' require('es6-promise').polyfill() Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', router, store, template: '<App/>', components: { App } }) // Home.vue <template> <div> <h3 class="ui center aligned header"> An

How can I upload image use ajax on the vue.js 2?

偶尔善良 提交于 2019-12-07 03:02:25
My component vue is like this : <template> <div class="modal" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <form method="post" :action="baseUrl+'/product/editImage'" enctype="multipart/form-data"> ... <input type="file" v-on:change="changeImage" name="image" id="image" required> ... </form> </div> </div> </div> </template> <script> export default{ ... methods: { changeImage(e) { data = new FormData(); data.append('file', $('#image')[0].files[0]); var imgname = $('#image').val(); var size = $('#image')[0].files[0].size; var ext = imgname