Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. 首先安装 Taro CLI:
  2.  
  3. ```bash
  4. $ npm i -g @tarojs/cli
  5. ```
  6.  
  7. 其次使用 CLI 工具把 Taro 组件转换为小程序组件,这里有两个参数,type 代表小程序平台, component 代表组件路径
  8.  
  9. ```bash
  10. $ taro build --type weapp --component path/to/your/component
  11. ```
  12.  
  13. 编译成功后会输出编译后的组件路径,在需要使用 Taro 组件的 wqvue 页面 json 中引用刚才的路径即可。
  14.  
  15. ```
  16. // pages/index.json
  17. {
  18. "usingComponents": {
  19. "example": "path/to/your/component"
  20. }
  21. }
  22. ```
  23.  
  24. 组件传参都在 `extraProps` 中,例如 `example` 组件有两个参数: `num`, `onChange`,我们需要这样做:
  25.  
  26. ```js
  27. // wxml
  28. <example extraProps="{{ exampleProps }}" />
  29.  
  30. // js
  31. new Wqvue({
  32. data: {
  33. exampleProps: {
  34. num: 5,
  35. onChange() {
  36. ...
  37. }
  38. }
  39. }
  40. })
  41. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement