如何修复 ractive.js 中的 "Could not find template for partial"?

How can I fix "Could not find template for partial" in ractive.js?

我正在尝试使用一个组件。我已经成功地激活了组件,但是由于某种原因这个组件不起作用:

var Ractive = require("ractive")

var log = console.log.bind(console);

var uploadComponent = Ractive.extend({
    isolated: false,
    template: 'test',
    data: {}
});

module.exports = uploadComponent;

产生错误:

Ractive.js: Could not find template for partial "previewVideo"

更新:正在使用的组件如下:

myapp/index.js

var previewVideo = require('component-preview-video');

new Ractive({
    el: $('.myapp-ui'),
    template: myAppTemplate,
    components: {
        previewVideo,
    ...many other components that work
    },
    oncomplete: function(){....}
},

myapp.mustache中:

{{>previewVideo}}

模板怎么会少?明明是存在的。 ractive 试图在哪里找到它?我该如何调试?

部件和组件是不同的(尽管在概念和功能方面有一些重叠)——如果 previewVideo 是一个组件,则需要像这样包含它:

<previewVideo/>

如果它 部分(虽然我猜不是,从示例代码)那么你会通过 partials 而不是 components:

var previewVideo = require('component-preview-video');

new Ractive({
  el: $('.myapp-ui'),
  template: myAppTemplate,
  partials: {
    previewVideo
  },
  oncomplete: function(){....}
});