小编iam*_*sha的帖子

如何解决模块解析失败:意外令牌 (11:9) react-router-native

我使用 yarn 安装了 react-native-router 并且只导入了 NativeRouter

这就是我从 react-router-native import { NativeRouter, Route, Link } from "react-router-native" 导入的方式;

这是我得到的错误

D:/WORKSHOP/Tunga/music-app/node_modules/react-router-native/NativeRouter.js 11:9
Module parse failed: Unexpected token (11:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|  */
| function NativeRouter(props) {
>   return <MemoryRouter {...props} />;
| }
|
Run Code Online (Sandbox Code Playgroud)

react-native react-router-native

6
推荐指数
1
解决办法
1293
查看次数

如何使用parcel-bundler将public目录中的所有文件添加到构建目录

我在 React 应用程序上使用 Parcel-Bundler。但我意识到我需要使用 HTTP 文件重定向所有文件 index.html,但是当我将 .htaccess 文件添加到我的公共目录时。构建项目后,它不会添加到 dist 文件夹中。

如何在构建后无需手动添加文件的情​​况下实现此目的?

javascript node.js reactjs devops parceljs

6
推荐指数
1
解决办法
2110
查看次数

无法读取未定义 CompileError 的属性“toLowerCase”:从 CSS 选择器 .invert-color 开始

我有一个项目,当我运行时工作正常,但当我运行或npm start 时失败并出现此错误npm run buildyarn build

Failed to compile.

Cannot read property 'toLowerCase' of undefined
CompileError: Begins at CSS selector .invert-color .form-checkbox input:checked,.invert-color .form-radio input:checked


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! open-react-template@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the open-react-template@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
...

Run Code Online (Sandbox Code Playgroud)

javascript node.js npm reactjs yarnpkg

5
推荐指数
0
解决办法
922
查看次数

代码分割不适用于反应中的包裹

我有这个组件,它来自包裹的文档。它说它应该默认工作。

import React from 'react';

const Router = () => {
 ...
  const ComponentToRender = React.lazy(() => import(`./Pages/${variableCompoentName}/index.js`));
  return (
    <React.Suspense fallback={<div>Loading...</div>}>
      <ComponentToRender />
    </React.Suspense>
  );
};

export default Router;

Run Code Online (Sandbox Code Playgroud)

但我在浏览器中收到错误消息:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

2src.7ed060e2.js:1362 Uncaught TypeError: Failed to fetch dynamically imported module: http://localhost:1234/Pages/Home/index.js
Run Code Online (Sandbox Code Playgroud)

有什么办法解决这个问题吗?我做错了什么?

这是我的 package.json

  "dependencies": {
    "@babel/core": "^7.12.3", …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs babeljs parceljs

5
推荐指数
1
解决办法
180
查看次数

如何在 PeerJs peer.call(id, stream, [options]) 函数中设置元数据?

我试图在对等连接中发送两个调用,并且我想通过 meta_data 区分它们,但当我检查 meta_data 时,我得到 null。如何在拨打电话时添加元数据?这是我当前的代码。

let cameracall = peer.call(conn.peer,ourcamera,{
    meta_data:JSON.stringify({ "type":"camera" })
});
let screencall = peer.call(conn.peer,ourscreen,{
meta_data:JSON.stringify({"type":"help"})
}); 
Run Code Online (Sandbox Code Playgroud)

这是文档对等调用的链接

javascript serialization webrtc peerjs

2
推荐指数
1
解决办法
1315
查看次数