vue - 单文件组件定义与使用
时间:2020-02-01 10:52:35
收藏:0
阅读:64
1、组件的定义
<template name="组件名称"> <view> ...... </view> </template> <script> export default { name: "组件名称", //组件外层属性 props: { 属性名称: { type: String,//属性类型 value: "值" }, ...... }, //组件生命周期 created:function(e){ },
//组件内部方法 methods: { 函数名称:function(obj){ }, } } </script> <style> 组件样式 </style>
2、组件的使用
1、引用依赖的组件 import 组件名称 from "../../components/组件名.vue"; 2、导出本组件时声明依赖的组件 export default{ components:{ 组件名称 }, } 3、在试图模板中使用组件 <组件名称 组件属性="对应的值"></组件名称>
评论(0)