-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好,出现一个问题 invalid componentPath: #9
Comments
用process.cwd()替代__dirname试试 |
有两种可能性: |
@kami1983 你可以将
const id = simulate.load(path.join(__dirname, '../components/index/index')) 试试 参考源码: /**
* 注册自定义组件
*/
function register(componentPath, tagName, cache) {
if (typeof componentPath === 'object') {
// 直接传入定义对象
const definition = componentPath
return jComponent.register(definition)
}
if (typeof componentPath !== 'string') {
throw new Error('componentPath must be a string')
}
if (!tagName || typeof tagName !== 'string') {
tagName = 'main' // 默认标签名
}
const oldLoad = nowLoad
const component = nowLoad = {
tagName,
json: _.readJson(`${componentPath}.json`),
}
if (!component.json) {
throw new Error(`invalid componentPath: ${componentPath}`)
} 实际上是要能获取组件对应的json配置文件的。 |
已经解决,谢谢大家! |
您好 我想请问下是如何解决的 因为我也遇到了这个问题 谢谢 |
问题应该出在“usingComponents” ,里头如果路径有问题就会造成 |
怎么解决的? |
小程序组件里usingComponents引用的是绝对路径的,运行时候也提示路径问题,invalid componentPath,现在是无法支持吗 |
配置 jest moduleNameMapper属性就可以了 https://jestjs.io/zh-Hans/docs/configuration#modulenamemapper-objectstring-string--arraystring |
无论我如何修改路径都是报错:invalid componentPath:
我的代码:(路径绝对是正确的,请问是什么原因造成的呢)
const id = simulate.load(path.join(__dirname, '../components/index')) // 加载自定义组件,返回组件 id
// const id = simulate.load('/components/index')
The text was updated successfully, but these errors were encountered: