Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 首先安装 Taro CLI:
- ```bash
- $ npm i -g @tarojs/cli
- ```
- 其次使用 CLI 工具把 Taro 组件转换为小程序组件,这里有两个参数,type 代表小程序平台, component 代表组件路径
- ```bash
- $ taro build --type weapp --component path/to/your/component
- ```
- 编译成功后会输出编译后的组件路径,在需要使用 Taro 组件的 wqvue 页面 json 中引用刚才的路径即可。
- ```
- // pages/index.json
- {
- "usingComponents": {
- "example": "path/to/your/component"
- }
- }
- ```
- 组件传参都在 `extraProps` 中,例如 `example` 组件有两个参数: `num`, `onChange`,我们需要这样做:
- ```js
- // wxml
- <example extraProps="{{ exampleProps }}" />
- // js
- new Wqvue({
- data: {
- exampleProps: {
- num: 5,
- onChange() {
- ...
- }
- }
- }
- })
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement