当前位置: 首页 > news >正文

uniapp renderjs页面传值

scrip标签里加 lang=“renderjs” ,可以使用原生js的dom,但是我在使用中发现以下问题,导致数据不能动态获取

1. onLoad获取上级页面传值 // APP不会触发,h5可以

2. props不会触发

解决办法添加 script 逻辑层数据传入渲染层 renderjs

<template><view class="content"><!-- @click="ezuikit.onClick" --><view class="preview" id="video-container" :prop="detail" :change:prop="ezuikit.receiveMsg"></view></view>
</template><script>import { monitordetail } from "@/api/all.js" // 获取数据的接口export default {data() {return {detail: { },};},created() {monitordetail({monitorId: uni.getStorageSync('monitorId')}).then(res=>{this.detail = {token: res.data.accessToken,url: res.data.url}})},methods: {// // 接收renderjs发回的数据// onViewClick(val) {// 	console.log('receiveRenderData-->', val);// }}};
</script><script module="ezuikit" lang="renderjs">import { monitordetail } from "@/api/all.js"var player = null;export default {data() {return {getData:{}}},mounted() {},methods: {// 接收逻辑层发送的数据receiveMsg(newValue, oldValue, ownerVm, vm) {// console.log('newValue', newValue)// console.log('oldValue', oldValue)this.getData = newValueif (typeof window.EZUIKit !== 'undefined') {this.initPlayer();} else {// 动态引入较大类库避免影响页面展示const script = document.createElement('script')// view 层的页面运行在 www 根目录,其相对路径相对于 www 计算script.src = 'static/ezuikit.js'script.onload = this.initPlayer.bind(this)document.head.appendChild(script)}},// onClick(event, ownerInstance) {// 	// 调用 service 层的方法// 	ownerInstance.callMethod('onViewClick', {// 		test: 'test'// 	})// },initPlayer() {}}}
</script><style>.content {margin-top: 30%;display: flex;flex-direction: column;align-items: center;justify-content: center;}
</style>
http://www.lryc.cn/news/469062.html

相关文章:

  • AI赋能R-Meta分析核心技术:从热点挖掘到高级模型、助力高效科研与论文发表
  • AMD锐龙8845HS+780M核显 虚拟机安装macOS 15 Sequoia 15.0.1 (2024.10)
  • 当事人单方委托专业机构或个人出具的书面意见,证据效力如何认定?
  • AUTOSAR CP 中 BswM 模块功能与使用介绍(2/2)
  • PCB电路板为什么大多是绿色的
  • Golang | Leetcode Golang题解之第508题出现次数最多的子树元素和
  • 【安全解决方案】深入解析:如何通过CDN获取用户真实IP地址
  • git 免密的方法
  • 如何用 obdiag 排查 OceanBase数据库的卡合并问题——《OceanBase诊断系列》14
  • hackme靶机渗透流程
  • uniapp 常用的地区行业各种多选多选,支持回显,复制粘贴可使用
  • iOS 本地存储地址(位置)
  • uni.showLoading 时禁止点击(防止表单重复提交) 小程序调取微信支付
  • OpenClash与Tailscale冲突得问题
  • day02|计算机网络重难点之HTTP请求报文和响应报文
  • Flutter之build 方法详解
  • 开源呼叫中心系统与商业软件的对比
  • 【人工智能】——matplotlib教程
  • 【c++ gtest】使用谷歌提供的gtest和抖音豆包提供的AI大模型来对代码中的函数进行测试
  • 使用Angular构建动态Web应用
  • 25届电信保研经验贴(自动化所)
  • 大数据-190 Elasticsearch - ELK 日志分析实战 - 配置启动 Filebeat Logstash
  • 不同类型的 LED 驱动电源在检测方法上有哪些不同?-纳米软件
  • android 生成json 文件
  • C++新增的类功能和可变参数模板
  • redo log 日志 与 undo log 日志工作原理
  • go语言结构体与json数据相互转换
  • jenkins 自动化部署Springboot 项目
  • 使用xml发送国际短信(smspro)【吉尔吉斯斯坦】
  • springmvc-springsecurity-redhat keycloak SAML2 xml实现