diff --git a/app.js b/app.js index 9c24c71..d59c13e 100644 --- a/app.js +++ b/app.js @@ -9,6 +9,7 @@ App({ }, globalData: { systeminfo: {}, + imageServer: 'https://images.weserv.nl/', config: { loginRequestUrlByMobile: 'https://juejin.im/auth/type/phoneNumber', loginRequestUrlByEMail: 'https://juejin.im/auth/type/email', diff --git a/components/jImage/jImage.js b/components/jImage/jImage.js new file mode 100644 index 0000000..89f529c --- /dev/null +++ b/components/jImage/jImage.js @@ -0,0 +1,22 @@ +Component({ + properties: { + src: { + type: String, + value: '', + observer: function (newVal) { + this.setSrc(newVal) + } + }, + }, + attached: function () { + this.setSrc(this.data.src) + }, + methods: { + setSrc (src) { + const imgSrc = `${getApp().globalData.imageServer}?url=${src}` + this.setData({ + imgSrc, + }) + } + }, +}) \ No newline at end of file diff --git a/components/jImage/jImage.json b/components/jImage/jImage.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/components/jImage/jImage.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/components/jImage/jImage.wxml b/components/jImage/jImage.wxml new file mode 100644 index 0000000..9a9e4db --- /dev/null +++ b/components/jImage/jImage.wxml @@ -0,0 +1 @@ + diff --git a/components/jImage/jImage.wxss b/components/jImage/jImage.wxss new file mode 100644 index 0000000..857a007 --- /dev/null +++ b/components/jImage/jImage.wxss @@ -0,0 +1,4 @@ +image.img { + width: 100%; + height: 100%; +} \ No newline at end of file