简体   繁体   English

Vue.js 2.0 从头开始​​组件

[英]Vue.js 2.0 start component from start

With vue.js 1.0 I started my router like this:使用vue.js 1.0 ,我像这样启动我的路由器:

router.start(App, 'app');

But this does not work anymore with vue.js 2.0 .但这不再适用于vue.js 2.0 According to the documentation I've to do it like this now:根据文档,我现在必须这样做:

const app = new Vue({
    router
}).$mount('app');

Is it possible to do it the old way?可以用旧方法吗? Because now I've to do this in my laravel blade file:因为现在我必须在我的laravel blade文件中执行此操作:

<div id="app">
    <router-view
            transition
            transition-mode="out-in">
    </router-view>
</div>

But I would like to do that ^ within a component.但我想在一个组件中这样做 ^。

you can wrap an element in your component with transition您可以使用transition将元素包装在组件中

Sample from docs来自文档的样本

<template>
  <div id="demo">
    <button v-on:click="show = !show">
      Toggle
    </button>
    <transition name="fade">
      <p v-if="show">hello</p>
    </transition>
  </div>
</template>

<script>
  new Vue({
    el: '#demo',
    data: {
      show: true
    }
  })
</script>

<style>
  .fade-enter-active, .fade-leave-active {
    transition: opacity .5s
  }
  .fade-enter, .fade-leave-active {
    opacity: 0
  }
</style>

Docs: vuejs transitions文档: vuejs 转换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM