开门见山
*官网中的注意事项:
1.强制谷歌内核(百度)
2.引入公众号图片使用
3.在meta中使用关键词和关键描述
4.顶部小图标
/*head中写*/
5.移动端适配
5.1 https://www.cnblogs.com/zr123/p/8178740.html移动端适配
5.2https://blog.csdn.net/a419419/article/details/79295799 dpr像素的解释
5.3https://www.zhangxinxu.com/study/201209/vw-vh-to-pixel.html浏览器/显示器宽度
5.4https://www.cnblogs.com/yanayana/p/7066948.html 5大布局的区别和联系
5.2媒体查询来引入不同移动端屏幕的样式或者引入rem.js响应式布局
6.使用框架,网页可以使用蚂蚁金服,后台可以使用iview
7.一般不需要引入字体因为加载的时候大会影响加载时间*
@baseColor:#FFB101;
@baseColor2:#F0A703;
@baseColor3:#28CD66;
@bgColor:#f8f8f8;
@red:#F64031;
/* Display Flex */
.disFlex{display:-ms-flexbox;display:-webkit-flex;display:flex;}
.vertical{display:-ms-flexbox;display:-webkit-flex;display:flex;flex-direction:column;-ms-flex-direction:column;-webkit-flex-direction:column;}
.vcenterFlex{display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-align:center;-webkit-align-items:center;align-items:center;justify-content: center;}
.Flex{-ms-flex:1;-webkit-flex:1;flex:1;}
.Flex-wrap{-ms-flex-wrap:wrap;-webkit-flex-wrap:wrap;flex-wrap:wrap;}
.Flex-top{-ms-flex-align:start;-webkit-align-items:flex-start;align-items:flex-start;}
.Flex-middle{-ms-flex-align:center;-webkit-align-items:center;align-items:center;}
.Flex-bottom{-ms-flex-align:end;-webkit-align-items:flex-end;align-items:flex-end;}
.Flex-center{-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;}
.Flex-right{-ms-flex-pack:end;-webkit-justify-content:flex-end;justify-content:flex-end;}
.Flex-between{-ms-flex-pack:justify;-webkit-justify-content:space-between;justify-content:space-between;}
.Flex-around{-ms-flex-pack:distribute;-webkit-justify-content:space-around;justify-content:space-around;}
/*行数省略*/
.clamp-1{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1; line-height: 1.5;}
.clamp-2{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2; line-height: 1.5;}
.clamp-3{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:3; line-height: 1.5;}
.clamp-4{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:4; line-height: 1.5;}
[v-cloak]{display: none;}
img{display:block;max-width: 100%;}
.hide{display:none!important;}
#app{
//字体颜色
}
.f999{
color: #999
}
.f666{
color: #666
}
.f555{
color: #555;
}
.f333{
color: #333;
}
// 品牌色
.ffbBg{
background:#ffb101!important;
}
.ffaBg{
background:#ffa203!important
}
.fffBg{
background:#fff !important;
}
/*缩放框固定中间两边改变*/
.box{
width:100%;
background:#fff;
.box-con{
position:relative;
width:75rem;
margin:0 auto;
}
}
JS
js文件一般写获取当前网页路径,获取网址参数,页面跳转方法,请求方法以及必须参数,倒计时,弹出窗口等等等等。。。
// 读取网址参数值
getUrlParameter : (_parameterName) => {
var r = window.location.search.substr(1).match(new RegExp("(^|&)" + _parameterName + "=([^&]*)(&|$)", "i"));
if (r != null) return unescape(r[2]);
return null;
},
/*获取根路径*/
window.Host = window.location.href.replace(/(.*)\/(.*)/, '$1/');
//请求方法(一般就封装成一个函数,需要的四个参数一般是static_api:function(_url,_data,success,fail))
window.static_api = (_url, _data, _success, _error) => {
if (_url.indexOf("http") === 0) _url = _url;
else _url = douleCom.Host + _url;
V.loading('请求中...');
Vue.http.post(_url, Object.assign({token:douleCom.userToken},_data), { emulateJSON: true ,timeout:5000,onTimeout:function(request){
console.info('超时处理');
}}).then(function(_res) {
V.close();
if(typeof _res.body == 'string') _res.body = JSON.parse(_res.body);
// 登陆失效
if(_res.body.info == 'vaildLogin') vaildLogin();
// 无权限
if(_res.body.info == 'validAuth') V.error('无权限进入当前页面');
_success(_res.body);
}).catch(function(_res) {
if(_res.status == 0 || !_res.ok) {
Vue.prototype.$Message.info({
content: '服务繁忙,请刷新页面...',
duration: 60,
closable: true,
onClose:function(){
window.location.reload(true)
}
});
}
if (_error) _error(_res)
})
}
Vue.component('doule-header',{
template:`
`,
methods:{
Jump:function(res){
// 多页面Vue所以跳转是用window.location.href
if(res == 'contact'||res =='honour'||res =='advantage'){
window.location.href = Host + 'about' +'.html?id='+ res
}else{
this.navType = res
window.location.href = Host + this.navType +'.html'
}
}
},
data(){
return {
navType:''
}
},
mounted(){
this.$nextTick(()=>{
this.navType = window.vm.navType/*获取使用改逐渐页面的navType*/
})
},
props:{
nav: String
},
watch:{
nav(res){
/*about页面比较复杂需要监听*/
this.navType = res
}
}
})
在使用组件的时候必须在页面引入这个组件!然后再HTML中《doule-header》《/doule-header》引入插件。
组件中引入图片使用了 src="${require(’…/image/logo.png’)}"是因为我设置了webpack压缩,在压缩后本地图片名字和路径会发生改变,所以需要在压缩前就获取到这个图片。这样压缩后的路径也会发生改变。同时多页面的组件和Vue-cli中的组件差别不大。
第二步开始制作啦
毫无疑问直接怼。首页遇到的小难点全部都是轮播图
轮播图使用了Vue-awesome-swiper插件(真的爆炸好用)
(3)书写修改标签,区分swiper
(4)Js部分
Window.vm。如果要获取父组件的对象,需要为父组件的标签添加ref属性,然后再获取
在进行交互或者设置缓存的时候,当出现[object , object]错误的时候需要先转为字符串然后再转为JSON格式。转的方法有JSON.stringify(),JSON.parse().