情况1
自定义 rem.js 文件
//px=>rem
(function (doc, win) {
var docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
recalc = function () {
var clientWidth = docEl.clientWidth;
if (!clientWidth) return;
if (clientWidth >= 840) {
docEl.style.fontSize = '150px';
} else if (clientWidth >= 640) {
docEl.style.fontSize = '100px';
} else {
docEl.style.fontSize = 100 * (clientWidth / 640) + 'px';
}
};
if (!doc.addEventListener) return;
win.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
index.js(或者main,js)中引入
import '../common-vue/rem';
情况2
自定义文件 dataparse.js
function GetyyyyMMdd(date) {
var curr_date = date.getDate();
var curr_month = date.getMonth() + 1;
var curr_year = date.getFullYear();
String(curr_month).length < 2 ? (curr_month = "0" + curr_month) : curr_month;
String(curr_date).length < 2 ? (curr_date = "0" + curr_date) : curr_date;
var yyyyMMdd = curr_year + "-" + curr_month + "-" + curr_date;
return yyyyMMdd;
}
export { //添加export抛出模块
GetyyyyMMdd
}
export 将方法“抛出”,在外部能获取到GetyyyyMMdd
index.js(或者main,js)中引入
import { GetyyyyMMdd } from '../common-vue/dataparse.js';
Vue.prototype.GetDateStr = GetyyyyMMdd;
vue中调用
<span class="link_detail">{{GetDateStr(item.start_time)}}至{{GetDateStr(item.end_time)}}</span>