|
@@ -1,6 +1,8 @@
|
|
|
<template>
|
|
|
<div class="test-comp">
|
|
|
<h1>组件测试页面</h1>
|
|
|
+ <TestComp1 str="hello world!"></TestComp1>
|
|
|
+ <!-- <TestComp1 v-bind:str="str1"></TestComp1> -->
|
|
|
<TestComp1></TestComp1>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -8,6 +10,24 @@
|
|
|
<script>
|
|
|
import TestComp1 from '@/components/TestComp1.vue'
|
|
|
export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ str1:{
|
|
|
+ userName:"张三"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 组件内 路由守卫 功能与路由配置文件中的beforeEnter相同
|
|
|
+ // to: 即将要进入的目标 路由对象
|
|
|
+ // from: 当前导航正要离开的路由
|
|
|
+ // next: Function 一定要调用该方法来执行下一步 是否跳转页面 next(true) 和 next() 放行可以进入当前页面 否则 next('/') 跳转到首页 传入一个path跳转到指定页面 next(false) 不放行
|
|
|
+ // beforeRouteEnter (to, from, next) {
|
|
|
+ // console.log(to, from, next)
|
|
|
+ // },
|
|
|
+ beforeRouteLeave (to, from, next) {
|
|
|
+ console.log(to, from, next)
|
|
|
+ next()
|
|
|
+ },
|
|
|
components:{
|
|
|
TestComp1
|
|
|
}
|