记录 taro3 的坑
作者:互联网
各依赖的版本如下
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/components": "3.0.25",
"@tarojs/react": "3.0.25",
"@tarojs/runtime": "3.0.25",
"@tarojs/taro": "3.0.25",
"react": "^16.10.0",
"react-dom": "^16.10.0"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@tarojs/mini-runner": "3.0.25",
"@tarojs/plugin-babel": "^2.2.10",
"@tarojs/webpack-runner": "3.0.25",
"@types/react": "^16.0.0",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^2.x",
"@typescript-eslint/parser": "^2.x",
"babel-preset-taro": "3.0.25",
"eslint": "^6.8.0",
"eslint-config-taro": "3.0.25",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^1.6.1",
"stylelint": "9.3.0",
"typescript": "^3.7.0"
}
坑
1、SyntaxError,代码编写正确
具体报错
VM33 WAService.js:2 MiniProgramError
missing ) after argument list
SyntaxError: missing ) after argument list
页面【pages/me/index]错误:
Error: module "pages/me/index.js" is not defined
at require (VM33 WAService.js:2)
at <anonymous>:120:9
at doWhenAllScriptLoaded (<anonymous>:155:21)
at Object.scriptLoaded (<anonymous>:175:5)
at Object.<anonymous> (<anonymous>:200:22)
原因:config文件夹下的配置文件导出错误
解决:导出使用 module.exports
替换module.exports
module.exports = {
env: {
NODE_ENV: '"development"'
},
defineConstants: {
SERVER_URL: "http://192.168.0.16:8080",
APP_KEY: "APP_KEY",
THEME_COLOR: "#36C38A"
},
mini: {},
h5: {}
}
为了保险起见,SERVER_URL的可以再用’'包裹,如:SERVER_URL: '"http://192.168.0.16:8080"'
2、引入taro-ui时出现找不到 “./style/index.scss”
具体报错
Error: Cannot find module 'taro-ui/dist/style/index.scss'
at webpackMissingModule (VM89 app.js:24)
at Object../node_modules/babel-loader/lib/index.js!./src/app.ts (VM89 app.js:24)
at __webpack_require__ (bootstrap:79)
at Module../src/app.ts (app.scss:1)
at __webpack_require__ (bootstrap:79)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at VM89 app.js:7
at require (VM71 WAService.js:2)
at <anonymous>:3:7
解决:安装 3.0.0-alpha 或 3.0.0-alpha.3 版本的 taro-ui
命令:npm install taro-ui@3.0.0-alpha.3 -D
后期遇到的坑会持续更新
标签:25,taro,taro3,记录,tarojs,js,eslint,3.0 来源: https://blog.csdn.net/weixin_42915204/article/details/114375326