c***@e-buy.com
c***@e-buy.com
  • 发布:2023-11-02 21:12
  • 更新:2023-11-02 22:56
  • 阅读:354

nvue使用BindingX监听页面滚动来控制头部导航显示,但是没效果

分类:nvue

代码如下,已经手动npm安装bindingx npm install weex-bindingx --save 就是死活没效果,请大佬帮忙看下什么问题?

<template>  
  <view class="content flex_center">  
    <comp-navbar page="index" ref="navbar_view"></comp-navbar>  
   ......  
  </view>  
</template>  
<script>  
const BindingX = uni.requireNativePlugin("bindingx");  
export default {  
    data() {  
       return {}  
   },  
   onReady() {  
    BindingX.bind({  
      eventType: "pan",  
      anchor: this.getEl(this.$refs.page_view),  
      props: [  
        {  
          element: this.getEl(this.$refs.navbar_view), //动画元素  
          property: "opacity", //动画属性  
          expression: "1-y/400" //表达式 说明了y从0-400,对应的值是1-0  
        },  
      ]  
    });  
  },  
methods: {  
    getEl: function(el) {  
      if (typeof el === "string" || typeof el === "number") return el;  
      // #ifdef APP-PLUS-NVUE  
      return el.ref;  
      // #endif  
      // #ifndef APP-PLUS-NVUE  
      return el instanceof HTMLElement ? el : el.$el;  
      // #endif  
    }  
}
2023-11-02 21:12 负责人:无 分享
已邀请:
喜欢技术的前端

喜欢技术的前端 - QQ---445849201

this.$refs.page_view 是 undefined

  • c***@e-buy.com (作者)

    没报这个错了

    2023-11-03 09:38

  • 2***@qq.com

    回复 c***@e-buy.com: 我的也没效果,请问作者怎么解决了

    2024-03-01 11:14

要回复问题请先登录注册