| 12345678910111213141516171819202122232425262728293031323334353637 |
- <template>
- <div>
- <h1>页面二</h1>
- <!-- 使用组件仅需 以组件名称为标签名即可 -->
- <h1> 当前组件内的数字为:{{ msg }}</h1>
- <!-- 可以为组件自定义事件名称 -->
- <AddControl v-bind:title="title" v-on:changeCount="childChange" ></AddControl>
- <AddControl title="累加器2"></AddControl>
- </div>
- </template>
- <script>
- // 引入组件 import from
- // import 后边为引入的组件名称 from 后边为组件的地址
- // vue 中 @ 表示 src 目录
- import AddControl from '@/components/AddControl.vue'
- export default {
- name: 'PageTwo',
- data(){
- return {
- title:'累加器11',
- msg:""
- }
- },
- methods:{
- childChange(count){
- console.log(count);
- this.msg = count;
- }
- },
- // components (注册组件)
- components: {
- // 组件的名称
- AddControl
- }
- }
- </script>
|