帖子
帖子
用户
博客
课程
显示全部楼层
69
帖子
2
勋章
480
Y币

[开发工具] 请完善AVM模块开发文档

[复制链接]
发表于 2021-11-28 11:07:49
需要使用vue slot的功能,但文档里没有。看官方的ACT组件库并没有使用文档里的组件开发方式,是使用的 React 的方式吗?请给出这种组件的开发文档。

10
帖子
1
勋章
5668
Y币
感谢提出优化开发文档的建议。

ACT组件库是使用的 render 函数来开发的,类似 React 的 JSX 。目前文档是有这种方式的介绍的。
https://docs.apicloud.com/apiclo ... ex=5&subIndex=2

另外AVM 在开发上来说,是可以React风格和Vue混编的。

如下是一个简单的例子,看看能否满足你的slot的功能:

// Main 父级页面
  1. <template>
  2.         <view class="page">
  3.                 <Test content={ <text>1</text> } />
  4.                         <demo content={ <text>2</text> } />
  5.         </view>
  6. </template>
  7. <script>
  8. import Test from '../../components/Test.js';
  9. import '../../components/Demo.stml';
  10. export default {
  11.         name: 'main',
  12. }
  13. </script>
  14. <style>
  15. .page {
  16.         height: 100%;
  17. }
  18. </style>
复制代码

// React 风格的组件:

  1. export default class Test extends Component {
  2.     render(props) {
  3.         return <view> {props.content} </view>
  4.     }
  5. }

  6. avm.define('Test', Test);
复制代码


// STML /VUE风格的组件:

  1. <template>
  2.         <view class="page">
  3.                 <text>demo.stml</text>
  4.                 <view> {{this.props.content}} </view>
  5.         </view>
  6. </template>
  7. <script>
  8. export default {
  9.         name: 'demo'
  10. }
  11. </script>
复制代码

69
帖子
2
勋章
480
Y币

感谢回答,下边这样怎么实现?
<Test><demo/></Test>
您需要登录后才可以回帖 登录

本版积分规则