美文网首页Vue
Vue模板定义

Vue模板定义

作者: ChangLau | 来源:发表于2018-08-29 11:05 被阅读1次

Vue模板定义

  • template定义
Vue.component('normal', {
    data() {
        return {

        }
    },
    template: `
        <div>
            <h1>Normal template</h1>
        </div>
    `
})
  • 内联定义
<inline-template inline-template>
    <div>
        <h1>内联模板</h1>
        <p>These are compiled as the component's own template.</p>
        <p>Not parent's transclusion content.</p>
    </div>
</inline-template>
Vue.component('inline-template', {
    data() {
        return {

        }
    }
})
  • X-Templates(script定义)
<script type="text/x-template" id="hello-world-template">
    <div>
        <h1>X-Templates模板</h1>
        <p>Hello hello hello</p>
    </div>
</script>
Vue.component('x-template', {
    data() {
        return {

        }
    },
    template: '#hello-world-template'
})

相关文章

  • Vue模板定义

    Vue模板定义 template定义 内联定义 X-Templates(script定义)

  • 路由嵌套

    模板抽离 我们已经学习过了Vue模板的另外定义形式,使用。 然后js里定义路由组件的时候: // 1. 定义(路由...

  • Vue学习之内联模板

    Vue学习之内联模板 在vue框架中,模板的位置有两种,一种是在组件内部定义,一种是在组件外部定义。我们首先来看内...

  • 自定义自己的vue-cli模板

    自定义自己的vue-cli模板 在使用vue-cli的过程中,常用的webpack模板只为我们提供最基础的内容,但...

  • 组件间通信与ajax的请求方式

    组件定义与使用 1. vue 文件的组成(3 个部分) 1)模板页面