checkVersion() {
if (typeof window !== 'undefined' && window && window.navigator && window.navigator !== undefined) {
let agent = window.navigator.userAgent, start = agent.indexOf("OS");
if ((agent.indexOf("iPhone") > -1 || agent.indexOf("iPad") > -1) && start > -1) {
return window.Number(agent.substr(start + 3, 3).replace("_", "."))
}
return 0;
}
},
const checkVersion = Common.checkVersion();
require("../assets/style.css");
require("../assets/style2.css");
require("../assets/sprite.css");
require("../assets/ondemandpagestyle.css");
require("../assets/newstyle.css");
require("../assets/landingpage.css");
if (checkVersion <= 14) {
require("../assets/styleIOSUpgrade.css");
}
这里你看到我有条件地需要最后一个CSS文件(根据IOS版本(,这里我使用CheckVersion函数来检测IOS版本,根据它,我需要不同的CSS文件
checkVersion() {
if (typeof window !== 'undefined' && window && window.navigator && window.navigator !== undefined) {
let agent = window.navigator.userAgent, start = agent.indexOf("OS");
if ((agent.indexOf("iPhone") > -1 || agent.indexOf("iPad") > -1) && start > -1) {
return window.Number(agent.substr(start + 3, 3).replace("_", "."))
}
return 0;
}
},
const checkVersion = checkVersion();
require("../assets/style.css");
require("../assets/style2.css");
require("../assets/sprite.css");
require("../assets/ondemandpagestyle.css");
require("../assets/newstyle.css");
require("../assets/landingpage.css");
if (checkVersion <= 14) {
require("../assets/styleIOSUpgrade.css");
}
U可以使用上面的代码有条件地要求CSS文件