components/my-canvas/index.js
import Render from './index.rjs'
Component({
data: {
value: 20,
},
lifetimes: {
代码: 全选
attached(props) {
this.rjs = new Render(this);
},
ready: function () {
this.setData({
value: this.data.info.progress
})
this.rjs.drawCircle('chart', this.data.info.progress, this.data.info.progressbarColor, this.data.info.page);
},
},
methods: {
handleStart(e){
const query = ty.createSelectorQuery();
const positon = query.select('#box').boundingClientRect();
this.rjs.handleStart(e);
},
handleMouseMove(e){
this.rjs.handleMouseMove(e,this.data.info.page);
},
handleMove(e){
this.rjs.handleMove(e, this.data.info.page);
},
animationPlay: function (val) {
this.setData({
value: val
})
this.data.info.progress = val
this.triggerEvent('onProgressChange', { val }); //这里这里这里这里这里这里这里这里这里
// console.log(this.data)
// this.data.watchChange(val)
},
},
})
你看,我这里就试着去用过this.triggerEvent('onProgressChange', { val }); 去将val值传到
page/diy/index.tsx
import Render from './index.rjs';
import Chart from "@/components/my-canvas/"
export function Diy() {
const [canvasData, setCanvasData] = useState(
{
progress: 60,
progressbarColor: '#ED4040',
page: 'temp',
}
);
const ctx = usePageInstance();
usePageEvent('onReady', function () {
const compInst = ctx.selectComponent('#canvasId');
console.log(compInst)
console.log(compInst.data.value)
const render = new Render(compInst);
render.getDOMByRJS();
});
return (
<>
<Chart key={activeTab} title={activeTab} info={canvasData} onChange={onProgressChange} id="canvasId" type="2d" />
</>
);
}
export default Diy;
中<Chart key={activeTab} title={activeTab} info={canvasData} onChange={onProgressChange} id="canvasId" type="2d" /> 这里绑定接收,是接收不到的