我有一个Vue组件,它有一个自定义的渲染方法.然而,该方法没有被调用.
<template>
<div class="guide"></div>
</template>
<script>
export default {
name: 'guide',
render: function(createElement){
return createElement('div', 'this will never get called?'),
},
};
</script>
Run Code Online (Sandbox Code Playgroud)
我查看了单个文件组件的文档,但没有提及有关render()的任何警告.还有另一种方法可以调用此方法吗?
dev*_*ill 10
正如ABDEL-RHMAN建议的那样,删除模板将导致代码工作; <template>
导致忽略render方法的原因.工作范例:
<script>
export default {
name: 'guide',
render: function(createElement){
return createElement('div', 'this will get called?'),
},
};
</script>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2573 次 |
最近记录: |