我有一个内联模板,我已经使用了拉拉维尔的刀片@include('my_inline_template'),这是很好的工作。
现在,我引入了其他人开发的另一个vue组件,并使用了.vue文件格式。我想将我的内联模板放在那个.vue文件中。
我想做的是如下所示,因为您不能在一个@include文件中使用.vue,所以它无法工作。我不知道还能做些什么,或者说这是可能的:
main-vue.js
import Component from './components/Component.vue'
require('./components/my_inline_template');
const vm = new Vue({
el: '#vue_root',
components: {
Component
}
});my_inline_template.js
Vue.component('my_inline_template', {
// blah
});my_inline_template.blade.php
<my_inline_template inline-template>
// blah
</my_inline_templateComponent.vue
<template>
<div>
@include('my_inline_template')
// More HTML
</div>
</template>
<script>
export default{
props: ['blah'],
data() {
return{
// blah
},
},
mounted() {
// blah
},
methods: {
// blah
}
}
</script>如何将my_inline_template包括在上面的.vue文件中?谢谢!
发布于 2017-06-11 02:13:10
我能够通过将组件分离成几个较小的组件来解决这个问题。这样,我就可以让.vue组件和内联模板在同一个刀片视图中相邻。然而,这并不是我问题的真正答案,所以如果有人想给我一个答案,我还是会感激的。
我的猜测是,您不能嵌套一个内联模板,它使用.vue文件中的刀片。
https://stackoverflow.com/questions/44468791
复制相似问题