2

I can't get a vue.js (version 1) transition to run. I took their code from their site. It should run the javascript console.logs!

 Vue.transition('fade', {
      css: false,
      enter: function (el, done) {
        console.log('enter');
      },
      enterCancelled: function (el) {
        console.log('enterCancelled');
      },
      leave: function (el, done) {
       console.log('leave');
      },
      leaveCancelled: function (el) {
        console.log('leaveCancelled');
      }
    });

     var Vue = new Vue({
      el: '#app',
      data: {
        
      }
    });
    <div id="app">
        <p transition="fade">test fade</p>
    </div>

1 Answer 1

2

With Vue.js’ transition system you can apply automatic transition effects when elements are inserted into or removed from the DOM.

The transition attribute can be used together with:

  • v-if
  • v-show
  • v-for

Try that :

Vue.transition('fade', {
    css: false,
	enter: function (el, done) {
		console.log('enter');
	},
	enterCancelled: function (el) {
		console.log('enterCancelled');
	},
	leave: function (el, done) {
		console.log('leave');
	},
	leaveCancelled: function (el) {
		console.log('leaveCancelled');
	}
});

var Vue = new Vue({
	el: '#app',
	data: {
		show: false
	}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.28/vue.min.js"></script>

<div id="app">
    	<button @click="show = !show">{{ show ? 'hide' : 'show' }}</button>
        <p v-show="show" transition="fade">test fade</p>
</div>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.