pass parameters in the background, which roughly means that users can personalize the configuration. Theme colors and backgrounds can be written in a separate sass,. You can use Vue.http to request a theme parameter before new a vm instance. In the entry file, you can use if () conditions to require
.
var axios_instance = axios.create({
transformRequest: [function(data) {
data = Qs.stringify(data);
return data;
}],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
Vue.prototype.$http = axios;
Vue.use(VueAxios, axios_instance);
Vue.use(Vuex);
Vue.axios.get('https://api.douban.com/v2/book/search', {
params: { //api
q: 'java'
}
}).then(res => {
if (res.status == 200) { //
require('./.../theme.sass'); // sass
}
})
const vm = new Vue({
el: '-sharpapp',
router,
store,
render: h => h(App)
});
personal test passed, and a little more code was referenced
gulp packages three sets of skins according to the sass configuration file, that is, color global variables. Online code dynamically switches link src
there should be a plug-in
as long as it is built with webpack, basically you can use the webpack-theme-color-replacer plug-in to dynamically change skin:
dynamically switch theme color
.