React 'component' 参数丢失错误?
React 'component' argument missing error?
我已经创建了 Header
组件。我正在将此反应 Header
组件与 meteor-blaze
一起使用,但我在控制台中收到错误消息,说反应参数组件丢失。我指的是这个文档 -> https://guide.meteor.com/react.html#blaze-in-react
league_header.html:
<template name="LeagueHeader">
{{#if isCordova}}
{{> HeaderMobile }}
{{else}}
<div>
{{> React component=Header }}
</div>
{{/if}}
</template>
headerhelper.js:
import { Template } from 'meteor/templating';
import './league_header.html';
import Header from '../../../imports/Header.jsx';
Template.LeagueHeader.helpers({
HeaderHelper() {
return Header;
}
})
Header.jsx:
import React, { Component } from 'react';
class Header extends Component {
render() {
console.log('Hello Component');
return (
<div>
<h2>Hello World</h2>
</div>
);
}
}
export default Header;
错误:
Error: In template "LeagueHeader", call to `{{> React ... }}` missing `component` argument.
at Blaze.View.<anonymous> (react-template-helper.js:23)
at blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1934
at Function.Template._withTemplateInstanceFunc (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:3744)
at blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1932
at Object.Blaze._withCurrentView (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:2271)
at viewAutorun (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1931)
at Tracker.Computation._compute (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:339)
at new Tracker.Computation (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:229)
at Object.Tracker.autorun (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:613)
at Blaze.View.autorun (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1944)
截图:
您使用的助手名称有误
尝试用这个替换组件调用。
{{> React component=HeaderHelper}}
我已经创建了 Header
组件。我正在将此反应 Header
组件与 meteor-blaze
一起使用,但我在控制台中收到错误消息,说反应参数组件丢失。我指的是这个文档 -> https://guide.meteor.com/react.html#blaze-in-react
league_header.html:
<template name="LeagueHeader">
{{#if isCordova}}
{{> HeaderMobile }}
{{else}}
<div>
{{> React component=Header }}
</div>
{{/if}}
</template>
headerhelper.js:
import { Template } from 'meteor/templating';
import './league_header.html';
import Header from '../../../imports/Header.jsx';
Template.LeagueHeader.helpers({
HeaderHelper() {
return Header;
}
})
Header.jsx:
import React, { Component } from 'react';
class Header extends Component {
render() {
console.log('Hello Component');
return (
<div>
<h2>Hello World</h2>
</div>
);
}
}
export default Header;
错误:
Error: In template "LeagueHeader", call to `{{> React ... }}` missing `component` argument.
at Blaze.View.<anonymous> (react-template-helper.js:23)
at blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1934
at Function.Template._withTemplateInstanceFunc (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:3744)
at blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1932
at Object.Blaze._withCurrentView (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:2271)
at viewAutorun (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1931)
at Tracker.Computation._compute (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:339)
at new Tracker.Computation (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:229)
at Object.Tracker.autorun (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:613)
at Blaze.View.autorun (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:1944)
截图:
您使用的助手名称有误 尝试用这个替换组件调用。
{{> React component=HeaderHelper}}