[英]I just installed Node.js and then React.js, need some spoonfeeding on how to display a single Semantic UI component
我实际上在这里有点不知所措。.我已经在google上搜索了很多,但是我还没有弄清楚如何在页面上看到React组件。。尽管我了解HTML的基础知识,但我对Web开发还是超级新手, CSS和JavaScript
这是我从安装Node开始一直遵循的所有步骤,它们是非常标准的步骤。
.pkg
安装节点 .bash_profile
sudo npm install create-react-app -g
,尽管我认为转到任何特定目录都不重要,因为-g
表示将在全局安装。 create-react-app project_name
npm start
:向我显示了一个带有漂亮React徽标的默认页面 create-react-app
步骤create-react-app
的同一文件夹project_name
中,我运行了npm install -g gulp
npm install semantic-ui --save
如语义UI网站上所列 npm audit fix
以解决一些它认为很关键的问题(运行此命令不会更改任何内容) project_name
文件夹中,我运行了cd semantic
semantic
,我做了gulp build
这就是我假设应该安装语义UI的方式。
现在,为了帮助您了解我的项目的结构,它看起来像这样:
所有这些文件都是在执行create-react-app..
并遵循我已完成的步骤时create-react-app..
的标准默认文件create-react-app..
我的App.js
甚至可以重新创建,它看起来像这样(我假设这个文件是将return()
内的内容呈现到位于目录public
中的index.html
中存在的root
div的组成部分,您可以在我的图像中看到该div。 。
在相同index.html
在public
文件夹,我也在添加这部分<head>
节
<link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script src="semantic/dist/semantic.min.js"></script>
我假设这是所有语义UI组件的组成部分。
假设我想查看语义UI的多选组件
此代码定义:
import React from 'react'
import { Dropdown } from 'semantic-ui-react'
const options = [
{ key: 'angular', text: 'Angular', value: 'angular' },
{ key: 'css', text: 'CSS', value: 'css' },
{ key: 'design', text: 'Graphic Design', value: 'design' },
{ key: 'ember', text: 'Ember', value: 'ember' },
{ key: 'html', text: 'HTML', value: 'html' },
{ key: 'ia', text: 'Information Architecture', value: 'ia' },
{ key: 'javascript', text: 'Javascript', value: 'javascript' },
{ key: 'mech', text: 'Mechanical Engineering', value: 'mech' },
{ key: 'meteor', text: 'Meteor', value: 'meteor' },
{ key: 'node', text: 'NodeJS', value: 'node' },
{ key: 'plumbing', text: 'Plumbing', value: 'plumbing' },
{ key: 'python', text: 'Python', value: 'python' },
{ key: 'rails', text: 'Rails', value: 'rails' },
{ key: 'react', text: 'React', value: 'react' },
{ key: 'repair', text: 'Kitchen Repair', value: 'repair' },
{ key: 'ruby', text: 'Ruby', value: 'ruby' },
{ key: 'ui', text: 'UI Design', value: 'ui' },
{ key: 'ux', text: 'User Experience', value: 'ux' },
]
const DropdownExampleMultipleSelection = () => (
<Dropdown placeholder='Skills' fluid multiple selection options={options} />
)
export default DropdownExampleMultipleSelection
我在哪个特定文件中添加此代码,并在执行npm start
时呈现/返回UI?
如果遵循上面列出的步骤,则可以从文件夹重新创建我的文件结构。
在App.js中尝试
import React, { Component } from 'react';
import DropdownExampleMultipleSelection from '/path/yourFile';
class App extends Component {
render() {
return (
<div>
<DropdownExampleMultipleSelection></DropdownExampleMultipleSelection>
</div>
);
}
}
export default App;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.