日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無(wú)先后,達(dá)者為師

網(wǎng)站首頁(yè) 編程語(yǔ)言 正文

快應(yīng)用開(kāi)發(fā)自定義事件 快應(yīng)用層級(jí) 圖片對(duì)象Image 獲取元素的寬高

作者:小強(qiáng)有個(gè)dream 更新時(shí)間: 2022-04-04 編程語(yǔ)言
  1. 自定義事件
// 父組件
<slidebar ontouchend="touchendFn()"></slidebar>
  touchendFn() {
    console.log(111)
  },
// 子組件
touchendFn() {
   console.log('touchendFn')
   this.$emit('touchend')
 },
  1. 快應(yīng)用層級(jí)
    // stack內(nèi)按先后順序?qū)盈B
<stack class="stack">
      <image class="image" src="pic2.webp"></image>
      <text class="title">stack容器排列方式為層疊,每個(gè)子組件按照先后順序依次堆疊,覆蓋前面的組件</text>
      <div class="wrap">
        <image class="btn" src="demo.png"></image>
      </div>
    </stack>
  1. 圖片對(duì)象Image

Image圖片對(duì)象需要等獲取后才能使用,否則報(bào)錯(cuò)Image is not defined

let canvas = this.$element('canvas')
// var ctx;
// if (canvas.getContext) {
//   ctx = canvas.getContext('2d');
// }
const image = new Image()
  1. 獲取元素的寬高
let canvas = this.$element('canvas')

canvas.getBoundingClientRect({
  success: (data) => {
      console.log(`getBoundingClientRect結(jié)果: width:${width}, height:${height},
       top:${top}, bottom:${bottom}, left:${left}, right:${right}`)
  }
});                                                    

原文鏈接:https://blog.csdn.net/qq_36413371/article/details/120842418

欄目分類(lèi)
最近更新