$ npx create-react-app react-cli-demo
Creating a new React app in exercise\react-cli-demo.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1368 packages in 2m
169 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm WARN deprecated source-map-resolve@0.6.0: See github.com/lydell/source-map-resolve#deprecated
added 38 packages in 9s
169 packages are looking for funding
run `npm fund` for details
Removing template package using npm...
removed 1 package, and audited 1406 packages in 4s
169 packages are looking for funding
run `npm fund` for details
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Created git commit.
Success! Created react-cli-demo at exercise\react-cli-demo
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can't go back!
We suggest that you begin by typing:
cd react-cli-demo
npm start
Happy hacking!
$ npm start
> react-cli-demo@0.1.0 start
> react-scripts start
(node:3880) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3880) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
Starting the development server...
Compiled successfully!
You can now view react-cli-demo in the browser.
Local: localhost:3000
On Your Network: 192.168.85.1:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
assets by path static/ 1.49 MiB
asset static/js/bundle.js 1.48 MiB [emitted] (name: main) 1 related asset
asset static/js/node_modules_web-vitals_dist_web-vitals_js.chunk.js 6.93 KiB [emitted] 1 related asset
asset static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg 2.57 KiB [emitted] (auxiliary name: main)
asset index.html 1.67 KiB [emitted]
asset asset-manifest.json 546 bytes [emitted]
cached modules 1.37 MiB (javascript) 31.3 KiB (runtime) [cached] 122 modules
webpack 5.69.1 compiled successfully in 1867 ms
// main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
react-cli-demo> npm i pubsub-js
added 1 package, and audited 1408 packages in 5s
169 packages are looking for funding
run `npm fund` for details
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
接着定义两个组件:
// 组件1订阅消息
// src/components/HelloWorld/index.jsx
import PubSub from 'pubsub-js'
export default function HelloWorld() {
// 订阅 message1
PubSub.subscribe('msg1', function (msg, data) {
console.log(msg, data);
});
return <div>hello world!</div>
}
// 组件2发布消息
// src/components/HelloWorld2/index.jsx
import PubSub from 'pubsub-js'
export default function HelloWorld() {
PubSub.publish('msg1', '旅游去');
return <div>hello world2!</div>
}
页面控制台显示:msg1 旅游去。
其他章节请看:
七天接手react项目 系列
标签:七天接手react项目系列
相关推荐
265860How can I optimize my English website to increase global traffic significantly?265874百度发帖子在哪里发布?快速找到入口及步骤指南?265881如何找到南沙地区专业的SEO优化专家进行网站推广?265890如何通过外贸运营新思维,构建数字化高效增长体系,超越传统模式?265900如何快速找到并设置百度盘授权权限的具体位置和步骤?265901抖音海盐SEO优化秘籍有哪些?分享一下吧!265909如何通过百度SEO优化和竞价代运营,制定全方位策略提升品牌在百度上的曝光率?265912如何运用实用技巧高效邀请新用户加入百度盘?265916百度里发布广告有哪些高效技巧,能让我快速吸引精准客户?265917外贸运营收费具体怎么计算?这份收费标准指南你了解吗?265919靠谱兼职项目里,有没有那种轻松赚钱且不费力的好选择呢?265923如何运用SEO答辩技巧,轻松实现网站排名提升?265929百度作为全球500强科技巨头,究竟排名第几令人好奇?265933芜湖SEO优化,如何合理布局长尾关键词以提升效果?265943无锡专业网站建设分类表有哪些?全面解析无锡网站建设领域都有哪些特点?265956外贸运营推广是做什么的?外贸运营推广新手如何入门?
$ npx create-react-app react-cli-demo
Creating a new React app in exercise\react-cli-demo.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1368 packages in 2m
169 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm WARN deprecated source-map-resolve@0.6.0: See github.com/lydell/source-map-resolve#deprecated
added 38 packages in 9s
169 packages are looking for funding
run `npm fund` for details
Removing template package using npm...
removed 1 package, and audited 1406 packages in 4s
169 packages are looking for funding
run `npm fund` for details
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Created git commit.
Success! Created react-cli-demo at exercise\react-cli-demo
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can't go back!
We suggest that you begin by typing:
cd react-cli-demo
npm start
Happy hacking!
$ npm start
> react-cli-demo@0.1.0 start
> react-scripts start
(node:3880) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3880) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
Starting the development server...
Compiled successfully!
You can now view react-cli-demo in the browser.
Local: localhost:3000
On Your Network: 192.168.85.1:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
assets by path static/ 1.49 MiB
asset static/js/bundle.js 1.48 MiB [emitted] (name: main) 1 related asset
asset static/js/node_modules_web-vitals_dist_web-vitals_js.chunk.js 6.93 KiB [emitted] 1 related asset
asset static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg 2.57 KiB [emitted] (auxiliary name: main)
asset index.html 1.67 KiB [emitted]
asset asset-manifest.json 546 bytes [emitted]
cached modules 1.37 MiB (javascript) 31.3 KiB (runtime) [cached] 122 modules
webpack 5.69.1 compiled successfully in 1867 ms
// main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
react-cli-demo> npm i pubsub-js
added 1 package, and audited 1408 packages in 5s
169 packages are looking for funding
run `npm fund` for details
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
接着定义两个组件:
// 组件1订阅消息
// src/components/HelloWorld/index.jsx
import PubSub from 'pubsub-js'
export default function HelloWorld() {
// 订阅 message1
PubSub.subscribe('msg1', function (msg, data) {
console.log(msg, data);
});
return <div>hello world!</div>
}
// 组件2发布消息
// src/components/HelloWorld2/index.jsx
import PubSub from 'pubsub-js'
export default function HelloWorld() {
PubSub.publish('msg1', '旅游去');
return <div>hello world2!</div>
}
页面控制台显示:msg1 旅游去。
其他章节请看:
七天接手react项目 系列
标签:七天接手react项目系列
相关推荐
265860How can I optimize my English website to increase global traffic significantly?265874百度发帖子在哪里发布?快速找到入口及步骤指南?265881如何找到南沙地区专业的SEO优化专家进行网站推广?265890如何通过外贸运营新思维,构建数字化高效增长体系,超越传统模式?265900如何快速找到并设置百度盘授权权限的具体位置和步骤?265901抖音海盐SEO优化秘籍有哪些?分享一下吧!265909如何通过百度SEO优化和竞价代运营,制定全方位策略提升品牌在百度上的曝光率?265912如何运用实用技巧高效邀请新用户加入百度盘?265916百度里发布广告有哪些高效技巧,能让我快速吸引精准客户?265917外贸运营收费具体怎么计算?这份收费标准指南你了解吗?265919靠谱兼职项目里,有没有那种轻松赚钱且不费力的好选择呢?265923如何运用SEO答辩技巧,轻松实现网站排名提升?265929百度作为全球500强科技巨头,究竟排名第几令人好奇?265933芜湖SEO优化,如何合理布局长尾关键词以提升效果?265943无锡专业网站建设分类表有哪些?全面解析无锡网站建设领域都有哪些特点?265956外贸运营推广是做什么的?外贸运营推广新手如何入门?