index.ts 522 B

1234567891011121314151617181920212223242526
  1. // index.ts
  2. // 获取应用实例
  3. const app = getApp<IAppOption>()
  4. Component({
  5. data: {
  6. width: 300,
  7. height: 300,
  8. renderWidth: 300,
  9. renderHeight: 300,
  10. },
  11. methods: {
  12. // 事件处理函数
  13. onLoad() {
  14. const info = wx.getSystemInfoSync();
  15. const width = info.windowWidth;
  16. const height = info.windowHeight;
  17. const dpi = info.pixelRatio;
  18. this.setData({
  19. width, height,
  20. renderWidth: width * dpi,
  21. renderHeight: height * dpi
  22. });
  23. },
  24. },
  25. })