change codefund
This commit is contained in:
parent
da5de5c689
commit
136d962c1e
|
@ -3,7 +3,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
import load from './load'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -27,10 +28,7 @@ export default {
|
||||||
? '111'
|
? '111'
|
||||||
: '96'
|
: '96'
|
||||||
const template = 'horizontal'
|
const template = 'horizontal'
|
||||||
axios.get(`https://codefund.io/properties/${codefundId}/funder.html?template=${template}`)
|
load(`https://app.codefund.io/properties/${codefundId}/funder.js?template=${template}`)
|
||||||
.then(function(response) {
|
|
||||||
document.getElementById('codefund').innerHTML = response.data
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
isGitee() {
|
isGitee() {
|
||||||
const origin = window.location.origin
|
const origin = window.location.origin
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
let callbacks = []
|
||||||
|
|
||||||
|
const dynamicLoadScript = (src, callback) => {
|
||||||
|
const cb = callback || function() {}
|
||||||
|
|
||||||
|
const script = document.createElement('script')
|
||||||
|
script.src = src // src url for the third-party library being loaded.
|
||||||
|
script.id = src
|
||||||
|
document.body.appendChild(script)
|
||||||
|
callbacks.push(cb)
|
||||||
|
const onEnd = 'onload' in script ? stdOnEnd : ieOnEnd
|
||||||
|
onEnd(script)
|
||||||
|
|
||||||
|
function stdOnEnd(script) {
|
||||||
|
script.onload = function() {
|
||||||
|
// this.onload = null here is necessary
|
||||||
|
// because even IE9 works not like others
|
||||||
|
this.onerror = this.onload = null
|
||||||
|
for (const cb of callbacks) {
|
||||||
|
cb(null, script)
|
||||||
|
}
|
||||||
|
callbacks = null
|
||||||
|
}
|
||||||
|
script.onerror = function() {
|
||||||
|
this.onerror = this.onload = null
|
||||||
|
cb(new Error('Failed to load ' + src), script)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ieOnEnd(script) {
|
||||||
|
script.onreadystatechange = function() {
|
||||||
|
if (this.readyState !== 'complete' && this.readyState !== 'loaded') return
|
||||||
|
this.onreadystatechange = null
|
||||||
|
for (const cb of callbacks) {
|
||||||
|
cb(null, script) // there is no way to catch loading errors in IE8
|
||||||
|
}
|
||||||
|
callbacks = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default dynamicLoadScript
|
Loading…
Reference in New Issue