我正在尝试将反应组件添加到流星项目中。当我在浏览器中运行它时效果很好但是当我在ios模拟器或设备上运行时,我会收到错误。
模板:
<template name="navbar_datepicker">
<div>
{{> React component=DesktopInfiniteCalendar}}
</div>
</template>
成分:
import React from 'react';
import { render } from 'react-dom';
import InfiniteCalendar from 'react-infinite-calendar';
import 'react-infinite-calendar/styles.css';
var today = new Date();
var minDate = Number(new Date()) - (24*60*60*1000) * 7; // One week before today
export default class DesktopInfiniteCalendar extends React.Component {
render() {
return (<InfiniteCalendar width={400} height={600} selectedDate={today} minDate={minDate} keyboardSupport={true} rowHeight={40} />);
}
}
助手:
import DesktopInfiniteCalendar from './datepicker_components.js';
Template.navbar_datepicker.helpers({
DesktopInfiniteCalendar() {
return DesktopInfiniteCalendar;
}
});
以上代码与meteor包react-template-helper结合使用,但仅在浏览器中使用。
我在模拟器和真实设备上遇到的错误是:
[Error] TypeError: null is not an object (evaluating 'document.body.appendChild')
exports (modules.js:43659)
(anonymous function) (modules.js:1645)
fileEvaluate (modules-runtime.js:180)
require (modules-runtime.js:109)
(anonymous function) (modules.js:809)
fileEvaluate (modules-runtime.js:180)
require (modules-runtime.js:109)
import (modules.js:394)
(anonymous function) (app.js:2657:539)
fileEvaluate (modules-runtime.js:180)
require (modules-runtime.js:109)
global code (app.js:13231)
有关为何会发生这种情况的任何想法?