<!-- 组件 -->
<myTest></myTest>
import myTest from "./components/myTest.vue"
components:{
myTest
},
data(){
return {
parentTitle:'父组件属性',
}
}
},
methods:{
parentFun(){
console.log('父组件方法');
}
}
<template>
<div>myTest页面</div>
</template>
data(){
return {
name:'子组件属性'
}
},
methods:{
childFun(){
console.log('子组件方法');
}
}
<!-- 组件 -->
<myTest ref="testComponent"></myTest>
console.log(this.$refs.testComponent.name);
this.$refs.testComponent.childFun();
props:["title"],
<!-- 组件 -->
<myTest ref="testComponent" :title="parentTitle"></myTest>
this.$emit('parentM');
this.$parent.parentFun();
params:/router1/:id ,/router1/123,/router1/789 ,这里的id叫做params
query:/router1?id=123 ,/router1?id=456 ,这里的id叫做query。
1:query方式传参和接收参数: