簡體   English   中英

如何將 Material Ui 與 Meteor 集成?

[英]How to integrate Material Ui with Meteor?

我正在嘗試將 Material Ui 與 meteor 集成,並作為示例測試嘗試執行以下但最終出現錯誤並且不知道如何解決它。 那里的任何人都可以幫助我解決此問題。 以下是一些需要跟蹤的細節。

我是怎么安裝的? --> 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............

對此有任何幫助嗎?

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

Material UI 是一個用於 React 的 UI 框架。 它不適用於 Blaze,而且我認為沒有任何方法可以在同一頁面中同時使用 Blaze 和 React。

要將 Material UI 添加到 Meteor/React 項目,請從命令行安裝 package:

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/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM