Skip to content

Instantly share code, notes, and snippets.

@actior
Created February 25, 2019 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save actior/74a107287a1ebbefcac0af55950ef541 to your computer and use it in GitHub Desktop.
Save actior/74a107287a1ebbefcac0af55950ef541 to your computer and use it in GitHub Desktop.
还是日常程序鱼的三分钟记忆
回顾之前写的代码,看一下,我草,这是谁写如此优美的代码(不就是我吗?o(*^@^*)o),再仔细看看。嗯....,好吧,这句是什么意思,我好像忘记它是谁了
```
<el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
```
请注意它(.native),作为退出界的懒人,时刻不忘记自己的指责。
子组件:(俺就是你爸爸,想点击我,请叫我爸爸);
父组件:....( ﹁ ﹁ ) ~→,以下请自脑补画面,
我们知道(.native)会变成为原生DOM的事件,意思就是可以直接用,如下:
根据Vue2.0官方文档关于父子组件通讯的原则,父组件通过prop传递数据给子组件,子组件触发事件给父组件。但父组件想在子组件上监听自己的click的话,需要加上native修饰符,故写法就像上面这样。
所以如果是普通的html就不需要,绑定事件就需要!✧(≖ ◡ ≖✿)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment