VueJS如何使用x-templates创建功能组件?

问题描述 投票:0回答:1

我想使用模板作为单文件组件来创建vueJS功能组件。我正在使用x-templates,因此我的组件将位于.html文件中。

例如,如何将以下组件变成功能组件?

<!-- my_component.html -->
<script type="text/x-template" id="my-component-template">
    <div>
        blah blah blah
    </div>
</script>

<script>
    Vue.component('my-component', {
        delimiters: ['[[', ']]'],
        template: '#my-component-template',
        props: {},
    })
</script>

我只能找到使用.vue文件的方法示例,在这种情况下,您将使用<template functional>。您如何使用x-templates做同样的事情?

javascript html vue.js
1个回答
0
投票

来自the docs

Vue.component('my-component', {
  functional: true,
})
© www.soinside.com 2019 - 2024. All rights reserved.