没有废话的vue进阶( 一 )

栏目: JavaScript · 发布时间: 7年前

内容简介:vue组件主要包含:方法一方法二

vue组件主要包含:

  1. 由vue-router产生的页面,可以称之为路由组件
  2. 独立基础组件:例如Date和input这之类的可以全局复用的基础组件
  3. 业务组件,除了以上两种就是业务组件

组件精髓

props

  • tppe 类型
  • default 默认
    • 如果是对象,数组,必须要写成方法进行返回
msg:{
    type: Array,
    default: ()=>([])
}
复制代码
  • validator 校验,有一个参数value
  • inheritAttrs 是否继承html特性
  • 子组件不能修改父组件传递过来的prop

event

方法一

<parent-com @on-click="handleClick"></parent-com>

子组件
<button>点击</button>
在子组件中触发
this.$emit('on-click', event);
复制代码

方法二

加上.native就是原生方法
<parent-com @click.native="handleClick"></parent-com>

子组件
<button>点击</button>
复制代码

slot

<slot> 节点就是指定的一个插槽的位置,v-slot:[name]可以指定插槽的位置,有了name就叫具名插槽


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Design and Analysis of Distributed Algorithms (Wiley Series on P

Design and Analysis of Distributed Algorithms (Wiley Series on P

Nicola Santoro / Wiley-Interscience / 2006-10-27 / USD 140.95

This text is based on a simple and fully reactive computational model that allows for intuitive comprehension and logical designs. The principles and techniques presented can be applied to any distrib......一起来看看 《Design and Analysis of Distributed Algorithms (Wiley Series on P》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

随机密码生成器
随机密码生成器

多种字符组合密码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器