vue-component

How to make a link as a file input in vue.js 2?

你离开我真会死。 提交于 2019-12-13 03:36:20
问题 My vue component like this : <template> ... <a href="javascript:;" class="thumbs" :title="upload"> <span class="fa fa-plus fa-2x"></span> </a> ... </template> <script> export default { props: ['...'], data() { return { ... }; }, computed:{ ... } } </script> I want if click the a link, it can upload file In javascript, I know it. If javascript like this : How to make a link act as a file input But How can I do it in vue.js 2? 回答1: I believe there is a small misunderstanding: Vue.js 2 is still

Add dynamically data-bound text in Vue.js

自作多情 提交于 2019-12-13 03:26:21
问题 My case must be weird, but I have a good for it. Here's my situation: I have a Vue app that renders a form based on a json. For example, the JSON: { "fields": [{ "name": "firstName", "title": "Name" }, { "name": "lastName", "title": "Last Name" }, { "title": "Hello {{ firstName }}!" }] } From that json, the final render has to be: <input type="text" name="firstName" v-model="firstName" /> <input type="text" name="lastName" v-model="lastName" /> <p>Hello {{ firstName }}</p> I'm able to render

Vue2: handling multi-child prop synchronization with models

人走茶凉 提交于 2019-12-13 03:17:24
问题 I'm new to Vue (about a, and while reading the docs is very helpful it is often the case where I can not derive how I am supposed to achieve the desired behavior. I have made several small components to get the feel for passing props and handling events, so now I am trying to makes something a bit larger but am facing some difficulty. This difficulty stems from the following: I would like to have a custom select component that are initialized via a v-for loop. All the while I would like to

Custom Vue Material md-Input how to get isDirty or isTouched

无人久伴 提交于 2019-12-13 03:16:59
问题 I would like to create my own CustomMdInput, with basic validation. I would like to implement a input that work that way: I use a <fp-input v-model="test"></fp-input> , and It is important, that when this input is required, when someone clicked on it or typesomething (turns 'touched' or 'dirty' property), and next defocus this input and go to the another input, the previous one stays Invalid with all the validation, so i have something like this: <template> <div class="md-layout-item"> <md

How can I add search country code on vue tel input?

你离开我真会死。 提交于 2019-12-13 03:15:45
问题 My vue component : <v-container> <v-row> <v-col cols="12" sm="6" md="3"> <vue-tel-input v-model="phone" v-on:country-changed="countryChanged"></vue-tel-input> </v-col> </v-row> </v-container> <v-btn color="success" @click="submit" > submit </v-btn> My codepen : https://codepen.io/positivethinking639/pen/XWWBXMW?editors=1011 I want display search like this : So make it easier for users to choose the country code How can I do it? 回答1: I think the simplest is to have two drop-downs side-by-side,

Vue - Set different favicon when browser online or offline

让人想犯罪 __ 提交于 2019-12-13 01:53:51
问题 I am trying to set different icons for when my browser is online(Normal logo) and offline(Greyed out logo). I am using Vue JS and I am able to detect online and offline set, I am also able to set different favicon for the different state but the offline icon won't show because my browser does not have internet to fetch the icon. What is the best approach to achieve this? The code I am using is below, btw I am using 'v-offline' to detect online or offline states handleConnectivityChange

How to create a hook with events between VUE 2.0 components

放肆的年华 提交于 2019-12-12 23:23:06
问题 I've created two dynamic components. Now, using events: $emit/$on what I need is to fire the "logThat(someObj)" method of the component-two passing the arguments as you can see in this fiddle: Vue.component('component-one', { template: '#template-a', methods: { onClick() { const someObj = { foo: "foo", bar: "bar" } vm.$emit('selected', someObj) vm.currentView ='component-two'; } } }); //Any hint?? /*vm.$on('selected', (someObj) => { this.logThat(someObj) })*/ Vue.component('component-two', {

vuejs - how to convert ajax loaded html into vuejs components

穿精又带淫゛_ 提交于 2019-12-12 21:44:57
问题 I have an #app container with some html, and I create Vue instance on the #app, all the content is compiled and converted to Vuejs components. Then I ajax in another html string, and I need to somehow compile that into components, how do I do that? 回答1: That is the use case for the template option, which can either reference to a <template> with specific ID in your DOM (like you do with your app using the el option), or directly your HTML template: Vue.component({ template: `<span class=

Using bootstrap-datetime picker with Vuejs 2

巧了我就是萌 提交于 2019-12-12 19:16:19
问题 I wanted to integrate Datetime picker with vue 2 or webpack. I tried searching but couldn't find related article. Have anyone integrated the Datetime picker with Vue2 or webpack, is there any sample code available for reference? Any help would be highly appreciated. Thanks. 回答1: You can sure find some issues on the subject by just Googling vuejs bootstrap datetimepicker , but honestly I'm not sure VueJS is well tailored to work with Bootstrap, that already have its own (jQuery) logic. There

vuejs 2 component base64 image not updating

独自空忆成欢 提交于 2019-12-12 19:05:41
问题 what i want to achieve: load an image from jwt token protected source the server return the image as base64 string and i'll load this string as background url on the image parent component: <template lang="html"> <myImage v-for="photo in form.photos" :photo="photo" @delphoto="deleteImage"></myImage> </template> export default { components: { myImage, }, data(){ return { form: { photos: [ { id: 1, thumbnail: "logo1.png" }, { id: 2, thumbnail: "logo2.png" }, { id: 3, thumbnail: "logo3.png" }, {