onMount
当在我的智能组件中触发时,我正在尝试渲染组件。服务器似乎正确地渲染了组件,但是当onMount
在客户端上触发时它没有渲染,我得到一个简单的undefined
.
const button = require('src/client/components/a-button');
console.log(button); // --> { path: '/home/karl/dev/instanty/node/src/client/components/a-button.marko.js', _: [Getter/Setter], '$__shouldBuffer': true, meta: {} }
const htmlServer = button.renderToString({ label: 'Click me!' }); // <-- works
console.log(htmlServer);
module.exports = class {
onMount() {
console.log(button); // --> Template {path: undefined, meta: undefined, _: function}
const html = button.renderToString({ label: 'Click me!' }); // <-- does not work
console.log(html);
}
//... more code
}
我需要此处所述的组件:http: //markojs.com/docs/rendering/#rendering
我也在使用套索,我怀疑这可能是它不起作用的原因。我怀疑套索没有捆绑组件并将其发送给客户端。
我还阅读了以下内容:http: //markojs.com/docs/lasso/#client-side-rendering