时间:2023-03-10 10:46:05 | 栏目:vue | 点击:次
引入、注册
<script> .... import CustomerModal from './modules/CustomerModal' export default { name: "CustomerList", mixins:[JeecgListMixin], components: { JDate, CustomerModal, JDictSelectTag }, ... } </script>
调用组件
<customer-modal ref="modalForm" @ok="modalFormOk"></customer-modal> // ref属性值指定了从$refs中获取组件的名称
this.$refs.modalForm.add();
this.$refs.modalForm.title = "新增";
严格来说,Vue子组件不能随便更改父组件传递过来的属性,但是可以这样修改
<component-a :num.sync="number">这是子组件</component-a>
<template> <div> <p @click="change">子属性{{num}}</p> </div> </template> <script> export default { name: "ComponentA", props: { num: Number }, methods: { change(){ this.$emit('update:num', 10) } } } </script>