![SMR工作室](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/001/80/90/07_avatar_mid.jpg?v=1652061576)
SMR工作室
- 发布:2022-10-28 10:09
- 更新:2022-10-28 16:08
- 阅读:1291
在手机中的浏览器测试是没问题的,但是运行到基座中就报错?是安卓不支持吗?如果不支持有什么相似的 api 可以在安卓中使用的吗?
![SMR工作室](http://img-cdn-tc.dcloud.net.cn/uploads/avatar/001/80/90/07_avatar_mid.jpg?v=1652061576)
SMR工作室 (作者)
<template>
<view class="app-box">
<view id="test" :style="{left:x+'rpx',top:y+'rpx'}" class="box" @click="test.onclick">
<text>{{'y : ' + y}}</text>
</view>
<view :style="{left:xx+'rpx',top:yy+'rpx',backgroundColor: 'red'}" class="box" @click="onclick1">
<text>{{'y : '+ yy}}</text>
</view>
</view>
</template>
<script setup lang="ts">
import {
ref
} from "vue"
const x = ref(0)
const y = ref(0)
const onclickEx = (cy: number) => {
console.log('@@@', cy);
y.value = cy
}
const xx = ref(300)
const yy = ref(0)
let hh = 0
const ss = 4
let pp = ss
const onclick1 = () => {
if (hh !== 0) {
clearInterval(hh)
hh = 0
} else {
hh = setInterval(() => {
if (yy.value >= 1000) {
pp = ss * 0 - ss
} else if (yy.value <= 0) {
pp = ss
}
yy.value = yy.value + pp
}, 1000 / 60)
}
}
</script>
<script module="test" lang="renderjs">
export default {
mounted() {
},
data() {
return {
x: 0,
y: 0,
s: 4,
p: this.s
}
},
methods: {
onclick(e, o) {
this.updateView(() => {
console.log(this.y);
if (this.y >= 1000) {
this.p = this.s * 0 - this.s
} else if (this.y <= 0) {
this.p = this.s
}
this.y = this.y + this.p
o.callMethod('onclickEx', this.y)
return false
})
},
updateView(fn) {
let lastFrameTime = 0
const animationFrame = (nowFrameTime) => {
let stopAnimation = false
if (lastFrameTime != 0) {
const oneFrameTime = Math.min(nowFrameTime - lastFrameTime, 100) / 1000
stopAnimation = fn(oneFrameTime) === false
}
lastFrameTime = nowFrameTime
if (!stopAnimation) {
requestAnimationFrame(animationFrame);
}
}
requestAnimationFrame(animationFrame);
}
}
}
</script>
<style lang="scss" scoped>
.app-box {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
.box {
width: 200rpx;
height: 200rpx;
background-color: #666;
position: absolute;
}
}
</style>
SMR工作室 (作者)
renderjs 支持 vue3 setup 吗? 我看文档似乎只支持 vue2 ?
2022-10-28 10:44
BoredApe
回复 SMR工作室: 这个和vue版本无关。支持的
2022-10-28 10:48
SMR工作室 (作者)
回复 BoredApe: 经过学习,我写了下 renderjs 的代码,在H5一切正常,在安卓基座是不报错了,但是好像点击事件没有触发?您能帮我看下吗?
2022-10-28 14:25
BoredApe
回复 SMR工作室: 代码怎么写的。截图或者上传一个测试工程
2022-10-28 14:28
SMR工作室 (作者)
回复 BoredApe: 我把 index.vue 上传在我下面的回复里了,麻烦您了,谢谢!
2022-10-28 14:29
SMR工作室 (作者)
回复 BoredApe:大佬不好弄吗?或者 uniapp 能直接调用安卓原生的动画帧 api 吗?我查到安卓 AnimationDrawable() 函数里面有 “getNumberOfFrames() :获取帧的动画数“ 方法,这个可以用 uniapp 调用吗?
2022-10-28 14:56
SMR工作室 (作者)
回复 BoredApe: 大佬,我测试了,requestAnimationFrame 可以正常执行,没问题,现在就是 ownerInstance.callMethod() 触发无效,很奇怪~
2022-10-28 15:24