<template functional>
<div class="test">
{{props.test.name}}
</div>
</template>
<script>
export default {
props: {
test: Object,
default: () => ({})
}
}
</script>
<template>
<div>
<test :test="{name: 'vue'}"></test>
</div>
</template>
<script>
import test from './test'
export default {
components: {
test
}
</script>
import Vue from 'vue'
Vue.component('test', {
functional: true,
props: {
test: {
type: Object,
required: true
}
},
render: function (createElement, context) {
return createElement(
'div',
{
attrs: {
class: 'test'
}
},
[context.props.test.name]
)
}
})
<template>
<div>
<test :test="{name: 'vue'}"></test>
</div>
</template>
<script>
import './test.js'
</script>
手机扫一扫
移动阅读更方便
你可能感兴趣的文章