自定义指令可以应用“v-name={value}”语法,如不雅要支撑指令参数和modifier可以用“v-name={{ value, modifier: true }}”语法:
- <script>
- import Vue from 'vue';
- Vue.directive('my-bold', {
- inserted: function (el) {
- el.style.fontWeight = 900;
- }
- })
- export default {
- props: ['onClick', 'isShow'],
- data() {
- return {
- test: 123
- };
- },
- methods: {
- afterLeave() {
- console.log('afterLeave')
- }
- },
- render() {
- const directives = [
- { name: 'my-bold', value: 666, modifiers: { abc: true } }
- ];
- return (
- <transition onAfterLeave={this.afterLeave} name="fade">
- <div class="test" onClick={this.onClick} v-show={ this.isShow } v-my-bold>
- {this.test}
- {this.isShow + ''}
推荐阅读
尴尬了:谷歌Android Samba应用仅支持不安全的SMBv1
近日谷歌初次推出其新的Android Samba应用,这显然不是好的宣布机会,因为在不久前,在重大年夜进击变乱中进击者就应用了该应用中安排的不安然版本SMB协定。比来几个月来,办事器消息块(SMBv1)协定中的马脚经由过程>>>详细阅读
本文标题:用Jsx写Vue组件
地址:http://www.17bianji.com/lsqh/36384.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示