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

學無先后,達者為師

網站首頁 編程語言 正文

快應用開發自定義事件 快應用層級 圖片對象Image 獲取元素的寬高

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

Image圖片對象需要等獲取后才能使用,否則報錯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結果: width:${width}, height:${height},
       top:${top}, bottom:${bottom}, left:${left}, right:${right}`)
  }
});                                                    

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

欄目分類
最近更新