钉钉小程序星级评分组件

前言

因为小程序引入了 colorUI 框架,请参照如下文章:

https://blog.csdn.net/weixin_43930421/article/details/124748879

组件截图

在这里插入图片描述

代码实现

在 components 文件目录下新建 rate 组件。

rate.axml

<view>
  <view>
    <text 
    	a:for="{
    {max}}" 
    	data-value="{
    {item}}" 
    	key="{
    {index}}" 
    	data-idx="{
    {index}}" 
    	onTap="change" 
    	class="reta-icon {
    {icon }} {
    {currentValue>=item?'activeColo
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
钉钉小程序中,父组件如何调用子组件的方法有多种方法。可以使用以下三种方式来实现: 1. 在父组件中通过组件选择器调用子组件的方法: 在父组件的方法中使用`this.selectComponent()`方法获取到子组件的实例,然后再调用子组件的方法。示例代码如下: ``` // 父组件调用子组件的方法 const childComponent = this.selectComponent('#childComponentId'); childComponent.childMethod(); ``` 2. 在父组件中通过事件触发子组件的方法: 在子组件中定义一个自定义事件,然后在父组件中通过`bind`关键字绑定该事件,并在事件回调函数中调用子组件的方法。示例代码如下: 在子组件中: ``` // 子组件定义自定义事件 Component({ methods: { childMethod() { // 子组件的方法逻辑 } } }) ``` 在父组件中: ``` <!-- 父组件模板中绑定子组件的自定义事件 --> <child-component bind:customEvent="parentMethod"></child-component> // 父组件中定义事件回调函数 const parentMethod = () => { // 父组件的方法逻辑 } ``` 3. 在父组件中使用`this.selectComponent()`获取到子组件实例,在子组件中定义一个方法可以供父组件调用。示例代码如下: 在子组件中: ``` // 子组件定义方法供父组件调用 Component({ methods: { childMethod() { // 子组件的方法逻辑 } } }) ``` 在父组件中: ``` // 父组件中调用子组件的方法 const childComponent = this.selectComponent('#childComponentId'); childComponent.childMethod(); ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值