| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- import { createSSRApp } from 'vue'
- import App from './App.vue'
- // #ifdef H5
- import VConsole from 'vconsole'
- // #endif
- // Polyfill for String.prototype.startsWith (for older browsers)
- if (!String.prototype.startsWith) {
- String.prototype.startsWith = function(search, pos) {
- pos = !pos || pos < 0 ? 0 : +pos
- return this.substring(pos, pos + search.length) === search
- }
- }
- // Polyfill for String.prototype.endsWith (for older browsers)
- if (!String.prototype.endsWith) {
- String.prototype.endsWith = function(search, this_len) {
- if (this_len === undefined || this_len > this.length) {
- this_len = this.length
- }
- return this.substring(this_len - search.length, this_len) === search
- }
- }
- // Polyfill for String.prototype.includes (for older browsers)
- if (!String.prototype.includes) {
- String.prototype.includes = function(search, start) {
- if (typeof start !== 'number') {
- start = 0
- }
- if (start + search.length > this.length) {
- return false
- } else {
- return this.indexOf(search, start) !== -1
- }
- }
- }
- // Polyfill for Array.prototype.includes (for older browsers)
- if (!Array.prototype.includes) {
- Array.prototype.includes = function(searchElement, fromIndex) {
- if (this == null) {
- throw new TypeError('"this" is null or not defined')
- }
- var o = Object(this)
- var len = o.length >>> 0
- if (len === 0) {
- return false
- }
- var n = fromIndex | 0
- var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0)
- while (k < len) {
- if (o[k] === searchElement) {
- return true
- }
- k++
- }
- return false
- }
- }
- // Polyfill for String.prototype.repeat (for older browsers)
- if (!String.prototype.repeat) {
- String.prototype.repeat = function(count) {
- if (this == null) {
- throw new TypeError("can't convert " + this + ' to object')
- }
- var str = '' + this
- count = +count
- if (count != count) {
- count = 0
- }
- if (count < 0) {
- throw new RangeError('repeat count must be non-negative')
- }
- if (count == Infinity) {
- throw new RangeError('repeat count must be less than infinity')
- }
- count = Math.floor(count)
- if (str.length == 0 || count == 0) {
- return ''
- }
- if (str.length * count >= 1 << 28) {
- throw new RangeError('repeat count must not overflow maximum string size')
- }
- var maxCount = str.length * count
- count = Math.floor(Math.log(count) / Math.log(2))
- while (count) {
- str += str
- count--
- }
- str += str.substring(0, maxCount - str.length)
- return str
- }
- }
- // Polyfill for String.prototype.padStart (for older browsers)
- if (!String.prototype.padStart) {
- String.prototype.padStart = function padStart(targetLength, padString) {
- targetLength = targetLength >> 0
- padString = String(typeof padString !== 'undefined' ? padString : ' ')
- if (this.length >= targetLength) {
- return String(this)
- } else {
- targetLength = targetLength - this.length
- if (targetLength > padString.length) {
- padString += padString.repeat(targetLength / padString.length)
- }
- return padString.slice(0, targetLength) + String(this)
- }
- }
- }
- // Polyfill for String.prototype.padEnd (for older browsers)
- if (!String.prototype.padEnd) {
- String.prototype.padEnd = function padEnd(targetLength, padString) {
- targetLength = targetLength >> 0
- padString = String(typeof padString !== 'undefined' ? padString : ' ')
- if (this.length >= targetLength) {
- return String(this)
- } else {
- targetLength = targetLength - this.length
- if (targetLength > padString.length) {
- padString += padString.repeat(targetLength / padString.length)
- }
- return String(this) + padString.slice(0, targetLength)
- }
- }
- }
- // 初始化vConsole用于移动端调试
- // #ifdef H5
- new VConsole()
- // #endif
- export function createApp() {
- const app = createSSRApp(App)
- return {
- app
- }
- }
|