vue自定义组件的总结(一)

1.定义组件时

<template>
  <input
    class="input"
    :type="type"
    :placeholder="placeholder"
    @focus="handleChange()"
    :style="style"
  />
</template>
 
在template里直接写功能标签,在父组件使用时,要在外面加一层div,所有事件操作不会在自定义组件标签上生效,但会在外层div生效
 
<div @change="handleInputAccountChange($event)">
      <input-box
        class="input-box inputAccountBox"
        :type="textType"
        :placeholder="inputAccount"
      />
</div>
posted @ 2020-11-16 14:00  弦歌是只前端大猫  阅读(75)  评论(0)    收藏  举报