vue-component

Using Vue to count up by seconds

随声附和 提交于 2019-12-04 05:16:17
I'm creating a small timer Vue component. A user needs to be able to start and stop that timer. Here's my component thus far: <template> <div> <a class="u-link-white" href="#" @click="toggleTimer"> {{ time }} </a> </div> </template> <script> export default { props: ['order'], data() { return { time: this.order.time_to_complete, isRunning: false, } }, methods: { toggleTimer() { var interval = setInterval(this.incrementTime, 1000); if (this.isRunning) { //debugger clearInterval(interval); console.log('timer stops'); } else { console.log('timer starts'); } this.isRunning = (this.isRunning ? false

Smoothly animate v-show in VueJS

左心房为你撑大大i 提交于 2019-12-04 05:07:21
I was trying to animated two divs using transition in Vuejs. Below is the code (jsfiddle) that I've used. But don't know why it's not working https://jsfiddle.net/k6grqLh1/16/ vue <div id="vue-instance"> <div> <transition name="fade"> <div v-show="show"> <div class="box yellow"></div> </div> </transition> <transition name="fade"> <div v-show="!show"> <div class="box blue"></div> </div> </transition> <a href="#" @click="show = !show">Change</a> </div> </div> css .fade-enter-active, .fade-leave-active { transition: opacity .5s } .fade-enter, .fade-leave-to /* .fade-leave-active in <2.1.8 */ {

Showing truncated text only on hover with Vue

落爺英雄遲暮 提交于 2019-12-04 04:55:22
问题 I tried it like this: <template> ... <b-card-group deck v-for="row in formattedClubs"> <b-card v-for="club in row" img-src="http://placehold.it/130?text=No-image" img-alt="Img" img-top> <h4 class="card-title" @mouseover="showAll = true" @mouseout="showAll = false"> {{getWord(club.description)}} </h4> <p class="card-text"> {{club.price}} </p> <p class="card-text"> {{club.country}} </p> <div slot="footer"> <b-btn variant="primary" block>Add</b-btn> </div> </b-card> </b-card-group> ... <

using summernote with vue.js 2

六眼飞鱼酱① 提交于 2019-12-04 04:49:01
问题 i want to use summernote in my vue.js 2 spa, and because not all my page using summernote so i make summernote to be a component by adding export default { editor_function(){ //summernote function in summernote.min.js } } and then i just import it in my .vue file that need summernote and call editor_function on mounted() function but i got error unknown codemirror when npm compile my vue project into single app.js file. so i went into just include summernote.min.js in my index.html and thats

Why two Vue.js identical components with different prop names give different results?

a 夏天 提交于 2019-12-04 04:11:33
问题 Codepen.io: https://codepen.io/xblack/pen/jXQeWv?editors=1010 HTML part : <div id="app"> <ul> <child-one :one="mydata"></child-one> <child-two :mydataTwo="mydata"></child-two> </ul> </div> <!-- child one template --> <script type="text/x-template" id="child-one"> <ul> LIST ONE <li v-for="item,i in one"> {{i}} {{item.name}} {{item.username.name}} {{item.email}} </li> </ul> </script> <!-- child two template --> <script type="text/x-template" id="child-two"> <ul> LIST TWO <li v-for="item,i in

Editing a form with save and cancel options

谁说我不能喝 提交于 2019-12-04 03:59:42
I'm new to VueJS. I'm trying to create a form with simple Save and Cancel functionality. When binding the model to form fields they get updated immediately as the inputs are changed, but I don't want that tight binding. Instead, I want to be able to save and submit when the "Save" button is pressed and revert the changes when the "Cancel" button is pressed. What's the suggested Vue way of doing this? It would also be ideal if we can show the server save status and indicate it on the form if the submission is failed. If you know of any examples or samples that would be hugely helpful. Thanks!

Use computed property in data in Vuejs

橙三吉。 提交于 2019-12-04 02:22:11
How can I use a computed property in the data or emit it via bus? I have the following vue instance, but myComputed is always undefined but computedData is working correctly. var vm = new Vue({ data(){ return{ myComputed: this.computedData } }, computed: { computedData(){ return 'Hello World' } } }) To make things as simple as possible, just do the work in watcher, unless you want to emit the changes to different components or there're a lot of variables you want to notify, then you may have to use Vuex or the event bus: var vm = new Vue({ data(){ return{ myComputed: '', computedData: 'Hello

Async Computed in Components - VueJS?

♀尐吖头ヾ 提交于 2019-12-03 22:58:58
Im finding a solution to async computed method in Components: Currently, my components is: <div class="msg_content"> {{messages}} </div> <script> export default { computed: { messages: { get () { return api.get(`/users/${this.value.username}/message/`, {'headers': { 'Authorization': 'JWT ...' }}) .then(response => response.data) } } }, } </script> Result: {} How to rewrite it in Promise mode? Because I think we can async computed by writing into Promise mode. Roy J Computed properties are basically functions that cache their results so that they don't have to be calculated every time they are

Keep-alive on a single route instaead of all routes in router-view

余生颓废 提交于 2019-12-03 15:54:29
问题 if keep-alive is specified to router-view as below <keep-alive> <router-view></router-view> </keep-alive> then all routes are effectively cached and reloaded when that route is revisited. I'd like to be able to specify a keep-alive option on individual routes. With many routes and only 1 or 2 that need to be kept alive wihout re-rendering caching all routes is useless is there any method of doing so or any workaround available 回答1: https://jsfiddle.net/Linusborg/L613xva0/4/ New in Vue version

Accessing nested child components in VueJS

青春壹個敷衍的年華 提交于 2019-12-03 14:42:46
问题 Using v2.2.2. I have the following structure in my VueJS app. How can I access all of the Account components from a method on my Post component? The number of Accounts is dynamic - I want to grab all of the loaded Account components and iterate over them. I know it's got something to do with $refs and $children , I just can't seem to figure out the right path. <Root> <Post> <AccountSelector> <Account ref="anAccount"></Account> <Account ref="anAccount"></Account> <Account ref="anAccount"><