ssan
ssan
  • 发布:2019-01-25 16:10
  • 更新:2019-10-25 15:28
  • 阅读:6317

uni-ui使用疑问

分类:uni-app

HBuilderX 版本1.5.2.20190121
使用 uni-ui
在 script 中引用组件:

import {uniBadge} from '@dcloudio/uni-ui'
//import uniBadge from '@dcloudio/uni-ui/lib/uni-badge/uni-badge.vue' //也可使用此方式引入组件
export default {
components: {uniBadge}
}
此方式能够正常使用;

// main.js

import {uniBadge} from '@dcloudio/uni-ui'
//import uniBadge from '@dcloudio/uni-ui/lib/uni-badge/uni-badge.vue' //也可使用此方式引入组件

Vue.component('uni-badge',uniBadge) //注意组件名必须是一个静态字符串
此方式编译错误;(编译到微信小程序/5+app)
错误信息如下:
Module build failed (from ./node_modules/@dcloudio/webpack-uni-mp-loader/lib/main.js):
16:07:13.919 TypeError: Cannot read property 'indexOf' of undefined
16:07:13.935 at Resolver.parse (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/enhanced-resolve/lib/Resolver.js:254:31)
16:07:13.936 at resolver.getHook.tapAsync (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/enhanced-resolve/lib/ParsePlugin.js:16:28)
16:07:13.953 at AsyncSeriesBailHook.eval [as callAsync] (eval at create (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
16:07:13.955 at Resolver.doResolve (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/enhanced-resolve/lib/Resolver.js:235:16)
16:07:13.974 at resolver.getHook.tapAsync (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:34:13)
16:07:13.976 at AsyncSeriesBailHook.eval [as callAsync] (eval at create (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
16:07:13.998 at Resolver.doResolve (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/enhanced-resolve/lib/Resolver.js:235:16)
16:07:13.999 at Resolver.resolve (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/enhanced-resolve/lib/Resolver.js:155:15)
16:07:14.022 at Object.resolve (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/webpack/lib/NormalModule.js:185:14)
16:07:14.023 at Promise (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/shared.js:16:10)
16:07:14.047 at new Promise (<anonymous>)
16:07:14.048 at Object.resolve (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/shared.js:15:10)
16:07:14.075 at Promise.all.Object.keys.map.name (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/main.js:68:22)
16:07:14.075 at Array.map (<anonymous>)
16:07:14.103 at Object.module.exports (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/webpack-uni-mp-loader/lib/main.js:67:60)

2019-01-25 16:10 负责人:无 分享
已邀请:
Neil_HL

Neil_HL

此版本在main.js里引入uni-ui有问题,HBuilderx下版本修复此问题

  • 1***@qq.com

    仍然没有解决啊?刚刚遇到

    2019-04-28 20:21

2***@qq.com

2***@qq.com

Uncaught Error: Module build failed (from ./node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js):
Error: babel-loader 查找失败

asdfasfsa

asdfasfsa

from ./node_modules/@dcloudio/webpack-uni-mp-loader/lib/script.js):
15:27:15.714 语法错误: Unexpected token (16:9)

该问题目前已经被锁定, 无法添加新回复