Comments (9)
用process.cwd()替代__dirname试试
from miniprogram-simulate.
有两种可能性:
1、可能环境判断不正确,重新安装一下 miniprogram-simulate 试试?保证这个包和相关依赖都是最新版本
2、路径不是绝对路径,可以输出一下 path.join(__dirname, '../components/index') 看看?
from miniprogram-simulate.
@kami1983 你可以将
const id = simulate.load(path.join(__dirname, '../components/index'))
改成
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配置文件的。
from miniprogram-simulate.
已经解决,谢谢大家!
from miniprogram-simulate.
已经解决,谢谢大家!
您好 我想请问下是如何解决的 因为我也遇到了这个问题 谢谢
from miniprogram-simulate.
问题应该出在“usingComponents” ,里头如果路径有问题就会造成
from miniprogram-simulate.
怎么解决的?
from miniprogram-simulate.
小程序组件里usingComponents引用的是绝对路径的,运行时候也提示路径问题,invalid componentPath,现在是无法支持吗
from miniprogram-simulate.
配置 jest moduleNameMapper属性就可以了 https://jestjs.io/zh-Hans/docs/configuration#modulenamemapper-objectstring-string--arraystring
from miniprogram-simulate.
Related Issues (20)
- About the license of components invoked by this Project. HOT 1
- 开启 virtualHost 之后,无法获取组件实例 HOT 2
- 开启 virtualHost 单测环境中渲染结果与官网描述不一致 HOT 2
- 使用comp.triggerLifeTime('ready')或者其他功能时,微信官方api(非wx.xxx)无法成功调用 HOT 3
- 是否支持 selectOwnerComponent HOT 4
- 能不能给一个搭配vitest的示例?
- How config miniprogram-simulate in Alipay mini program HOT 3
- Uniapp 编写的小程序可以使用么 HOT 1
- 在调用comp.detach()后. jest测试框架 的test函数无效. 报错:NotFoundError: The node to be removed is not a child of this node. HOT 4
- 无法测试报错的情形啊 HOT 1
- 我这样试了下貌似没有出现你说的问题,有没有具体的 demo?
- 能否加入在使用Component API 建立page时,可测试页面组件特性 HOT 2
- 使用插件导致编译出错 HOT 5
- getStorageSync 套了一层JSON.parse,传入如果存入字符串,获取就会报错 HOT 3
- TypeError: wx.nextTick is not a function HOT 1
- Cannot find module 'pretty-format/build/plugins/lib/markup' from 'node_modules/miniprogram-simulate/src/jest-snapshot-plugin.js' HOT 2
- pretty-format依赖应声明为dependencies
- view 的 animation 属性,会导致组件无法渲染,该怎么处理
- ReferenceError: getCurrentPages is not defined HOT 1
- spawnSync ENOENT HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miniprogram-simulate.