【问题标题】:How to integrate Material Ui with Meteor?如何将 Material Ui 与 Meteor 集成?
【发布时间】:2020-10-01 01:35:30
【问题描述】:

我正在尝试将 Material Ui 与流星集成,并作为示例测试尝试执行以下操作,但最终出现错误并且不知道如何解决它。那里的任何人都可以帮助我解决此问题。以下是一些需要跟踪的细节。

我是如何安装的? --> meteor npm install @material-ui/core

我如何集成代码?通过 Blaze React 组件

ExampleTest.js

Template.ExampleTest.helpers({
  ExampleContainer() {
      return ExampleContainer;
    }
  });

ExampleContainer.js

const ExampleContainer = withTracker(() => {
---------
})(Example);

Example.js

import React, { Component } from "react";
import { Button } from "@material-ui/core";

class Example extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
      <Button color="primary">Hello World</Button> 
      </div>
    );
  }
}

export default Example;

我收到了什么错误?

Error: In template "ExampleTest", call to `{{> React ... }}` missing `component` argument.
    at Blaze.View.<anonymous> (react-template-helper.js?hash=3fb2a2954362a4acdee8150fb77f0f500dd28206:67)
    at blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:1934
    at Function.Template._withTemplateInstanceFunc (blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:3769)
    at blaze.js?hash=cbd85c3fe14949f2d2b9a3b76334f5f0e96d553c:1932............

对此有任何帮助吗?

【问题讨论】:

    标签: meteor material-ui


    【解决方案1】:

    看起来您正在使用 Blaze 模板引擎。你应该改用 React。 https://www.meteor.com/tutorials/react/components

    【讨论】:

    • 嗨@MinhNguyen 抱歉错过了您的回复。我保留了这个要求,因为我的整个项目都在使用 Blaze 组件,并且不知道如何管理 Blaze 和 react 组件。感谢您的快速支持:)
    【解决方案2】:

    Material UI 是一个用于 React 的 UI 框架。它不适用于 Blaze,而且我认为没有任何方法可以在同一页面中同时使用 Blaze 和 React。

    要将 Material UI 添加到 Meteor/React 项目,请从命令行安装包:

    npm install @material-ui/core
    

    并在 HTML 的头部包含 Roboto 字体:

    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
    

    对我来说,这很有效,Meteor 没有什么特别需要的。

    更多说明:https://material-ui.com/getting-started/installation/

    【讨论】:

    • 我不认为有任何方法可以在同一页面中同时使用 Blaze 和 React”:实际上有,请参阅 React components in Blaze
    猜你喜欢
    • 1970-01-01
    • 2019-08-02
    • 2021-02-21
    • 2015-11-09
    • 2018-05-29
    • 1970-01-01
    • 2020-05-16
    • 1970-01-01
    • 2016-08-25
    相关资源
    最近更新 更多