当前位置: 首页 > news >正文

站网站推广高手做网站

站网站推广,高手做网站,wordpress音乐网站主题,整站优化多少钱组件是什么 vue组件就是一个个独立的小型的ui模块#xff0c;整个大型的系统就是由一个个小型的UI模块拼接而成的 vue组件就是vue实例#xff0c;通过new Vue函数来创建的一个vue实例#xff0c;不同的组件只不过是options的不同#xff0c;我们基本百分之90的开发工作都…组件是什么 vue组件就是一个个独立的小型的ui模块整个大型的系统就是由一个个小型的UI模块拼接而成的 vue组件就是vue实例通过new Vue函数来创建的一个vue实例不同的组件只不过是options的不同我们基本百分之90的开发工作都是围绕options的配置来进行的 三大核心概念 属性、事件、插槽 属性 属性例子 export default {name: PropsDemo,// 不推荐使用这种做法不利于维护// props: [name, type, list, isVisible],// 建议使用下面的做法来声明属性(使用对象的形式声明)props: {name: String,type: {validator: function(type) {// 这个值必须匹配以下字符串中的一个return [success, warning, danger].includes(value);}},list: {type: Array,// 对象或数组默认值必须从一个工厂获取default: () []},isVisible: {type: boolean,default: false},// 不建议使用onChange来命名会和语法冲突onChange: {type: Function,default: () {}}} }属性使用方法 Props.vue文件内容如下 templatedivname: {{ name }}brtype: {{ type }}brlist: {{ list }}brisVisible: {{ isVisible }}brbutton clickhandleClickchange type/button/div /templatescript export default {name: PropsDemo,// 自动挂载属性inheritAttrs: false,props: {name: String,type: {validator: function(value) {return [success, warning, danger].includes(value);}},list: {type: Array,default: () []},isVisible: {type: Boolean,default: false},onChild: {type: Function,default: () {} }},methods: {handleClick() {// 不可以这么做会报错, 因为我们的属性是单向数据流的不允许在子组件内更改父组件传递过来的值// this.type warning;console.log(触发)console.log(子组件的type是)console.log(this.type)this.onChild(123)}} } /scriptApp.vue文件使用如下 divPropsnameHello Vue!:typetype:is-visiblefalse:on-childhandlePropChangetitle属性Democlasstest1:class[test2]:style{ marginTop: 20px }stylemargin-top: 10px;//divscript import Props from ./components/Props.vue;export default {name: App,components: {TodoItem,Props,// Event},data() {return {msg: hello geek!,info: ,list: [],type: success,name: 事件名}},methods: {handleClick() {if (this.info ! ) {this.list.push(this.info)this.info }},handlePropChange(param) {console.log(param)console.log(父组件)if (this.type success) {this.type warning} else {this.type success}console.log(父组件的type)console.log(this.type)},handleEventChange() {}} } /script 子组件中对属性进行了封装全部在Props中当父组件使用时通过:属性名称的方式进行引用和赋值 子组件定义了一个函数的属性onChild在父组件使用这个属性时也是和使用普通组件一样的方式对onChild进行赋值只不过赋的是函数是的函数也是作为参数来存在 此函数可以接收参数是否接收参数接收什么参数取决于子组件对此函数的定义可以看到子组件中有一个 handleClick方法方法内部对onChild进行了调用并传递参数123当父组件的handlePropChange方法在接收函数时也定义了一个参数用来接收(param) handlePropChange(param) {console.log(param)console.log(父组件)if (this.type success) {this.type warning} else {this.type success}console.log(父组件的type)console.log(this.type)}事件 定义 Even.vue文件 templatedivname: {{ name || -- }}brinput :valuename changehandleChangebr/br/div clickhandleDivClickbutton clickhandleClick重制成功/buttonbutton click.stophandleClick重制失败/button/div/div /templatescript export default {name: EventDemo,props: {name: {type: String}},methods: {handleChange(e) {console.log(改变1)this.$emit(change, e.target.value)console.log(改变2)console.log(e.target.value)},handleDivClick() {console.log(清空)this.$emit(change, )},handleClick() {// 无论做什么都会失败// e.stopPropagation();}} } /script父组件引用方法 Event :nameeventName changehandleEventChange/// 导入 import Event from ./components/Event.vue;// 方法定义 handleEventChange(param) {console.log(父组件接收到change事件)if (param?.target?.value) {this.eventName param?.target?.valueconsole.log(param?.target?.value)} else {this.eventName } }子组件定义方法: handleChange通过this.$emit(change, e.target.value)调用change方法传递当前输入框的值作为参数 父组件通过handleEventChange函数进行接收并声明一个参数param通过param中的param?.target?.value来获取传递的参数值 插槽 组件文件夹内新建文件Slot.vue templatedivslot /slot nametitle /slot nameitem v-bind{ value: vue } //div /template script export default {name: SlotDemo } /script父组件引用部分 SlotDemotemplate v-slot:titleptitle slot1/pptitle slot2/p/templatetemplate v-slot:itempropspitem slot-scope {{ props }}/p/template /SlotDemo// js引用 import SlotDemo from ./components/Slot.vue;子组件通过定义nametitle的插槽、nameitem的插槽父组件通过v-slot:title和v-slot:itemprops来引用子组件定义的插槽 总结
http://www.hkea.cn/news/14523557/

相关文章:

  • vs2008怎么做网站百度网站如何做运营
  • 电子商务网站建设与管理最新试卷u钙网免费设计头像
  • 谷歌seo技巧seo营销排名
  • 商品定制平台网站WordPress怎么取消邮箱注册
  • 阜阳建设工程质量监督局网站专业做企业网站
  • python django做的网站相机拍照的图片怎么做网站呀
  • 网站群系统wordpress 小公举
  • 常州模板网站建设企业wordpress如何用API采集
  • 网站制作费用大概多少牛魔王网站建设
  • 软件开发培训学校porin深圳优化公司公认安高粱seo
  • 百度模板网站模板北京微信网站建设电话
  • 奥远网站建设流程有了自己的网站怎么赚钱
  • 有哪些营销型网站快点tv下载安装
  • 中文域名交易网站产品软文模板
  • 网页网站设计培训网站设计及内容策划
  • 婚礼策划网站黄埔区网站建设
  • 企业网站如何制作wordpress侧边栏二级菜单
  • 用vue做网站惠州app开发公司
  • 快站优惠券app网页跳转链接怎么制作
  • 如何做网站浏览pdf山东建设项目环境影响登记网站
  • 做环保是跑还是网站卖博物馆 网站 建设
  • 网站的设计思想今天的军事新闻
  • 网站建设招标提问网站建设手机端官网
  • 国外做网站推广网站二次开发的模板种类
  • 站长工具国色天香莱钢吧贴吧
  • 专门做照片书的网站门户网站cms系统
  • 商务网站建设模块手机高端设计网站建设
  • 威海网站建设地址wordpress的站点地址如何配置
  • 我想自己做网站可以赚钱租车行网站模版
  • 怎么做网站啊网站增加外链的方法有哪些