npm install\ babel-plugin-syntax-jsx\ babel-plugin-transform-vue-jsx\ babel-helper-vue-jsx-merge-props\ babel-preset-es2015\ --save-dev
{
"presets": ["es2015"],
"plugins": ["transform-vue-jsx"]
}
<script>
export default {
props: ['onClick', 'isShow'],
data() {
return {
test: 123
};
},
render() {
return (
<div class="test" onClick={ this.onClick }>
{ this.test }
{ this.isShow + '' }
</div>
);
}
}
</script>
render (h) {
return (
<div
// normal attributes or component props.
id="foo"
// DOM properties are prefixed with `domProps`
domPropsInnerHTML="bar"
// event listeners are prefixed with `on` or `nativeOn`
onClick={this.clickHandler}
nativeOnClick={this.nativeClickHandler}
// other special top-level properties
class={{ foo: true, bar: false }}
style={{ color: 'red', fontSize: '14px' }}
key="key"
ref="ref"
// assign the `ref` is used on elements/components with v-for
refInFor
slot="slot">
</div>
)
}
render (h) {
return h('div', {
// Component props
props: {
msg: 'hi'
},
// normal HTML attributes
attrs: {
id: 'foo'
},
// DOM props
domProps: {
innerHTML: 'bar'
},
// Event handlers are nested under "on", though
// modifiers such as in v-on:keyup.enter are not
// supported. You'll have to manually check the
// keyCode in the handler instead.
on: {
click: this.clickHandler
},
// For components only. Allows you to listen to
// native events, rather than events emitted from
// the component using vm.$emit.
nativeOn: {
click: this.nativeClickHandler
},
// class is a special module, same API as `v-bind:class`
class: {
foo: true,
bar: false
},
// style is also same as `v-bind:style`
style: {
color: 'red',
fontSize: '14px'
},
// other special top-level properties
key: 'key',
ref: 'ref',
// assign the `ref` is used on elements/components with v-for
refInFor: true,
slot: 'slot'
})
}
<template>
<div class="wrapper">
<Test :on-click="clickHandler" :is-show="show"></Test>
</div>
</template>
<script>
import Test from './Test.vue';
export default {
name: 'hello',
components: {
Test
},
data() {
return {
msg: 'Welcome to Your Vue.js App',
show: true
};
},
methods: {
clickHandler(){
this.show = !this.show;
}
}
};
</script>
<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 + ''}
</div>
</transition>
);
}
}
</script>
<style>
.fade-enter-active, .fade-leave-active {
transition: opacity .5s
}
.fade-enter, .fade-leave-to {
opacity: 0
}
</style>
const directives = [
{ name: 'my-dir', value: 123, modifiers: { abc: true } }
]
return <div {...{ directives }}/>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有