项目相关
公共API接口
javascript
// 卖座网API
// 正在热映:https://m.maizuo.com/gateway?cityId=310100&pageNum=1&pageSize=10&type=1&k=9925800
// 即将上映:https://m.maizuo.com/gateway?cityId=310100&pageNum=1&pageSize=10&type=2&k=9925800
规避跨域请求头
javascript
headers:{
// 设置请求头规避跨域问题
"X-Host": "mall.film-ticket.film.list",
"X-Client-Info": '{"a":"3000","ch":"1002","v":"5.2.1","e":"16903322302568072615428097"}'
}
引入模块顺序建议
javascript
引入模块顺序建议:首先内置模块,其次第三方模块,JS文件,组件,Style
复选框单选功能
js
// 使用element中的table组件
<el-table
ref="table"
v-skeleton="{loading:loading,rows: 10}"
:data="list"
empty-text=" "
style="width: 100%;margin-top: 6px"
:header-cell-style="{fontSize: '14px', backgroundColor: '#e7f3ff',color:'#909399'}"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" />
// 单元格中只能选择一个
// 单元格选中获取实例 val:当前行对象
handleSelectionChange(val) {
// 获取勾选的用户id
const idList = this.$refs.table.selection.map(item => item.id)
this.checkedIdNum = idList[idList.length - 1]
// 设置多选框 只选中一个
this.list.forEach(item => {
if (item === val[val.length - 1]) {
this.$refs.table.toggleRowSelection(item, true)
} else {
this.$refs.table.toggleRowSelection(item, false)
}
})
},
加密解密
ts
import * as CryptoJS from 'crypto-js';
const message = "Hello, world!";
const secretKey = "mySecretKey";
// 加密
const ciphertext = CryptoJS.AES.encrypt(message, secretKey).toString();
console.log("Encrypted:", ciphertext);
// 解密
const bytes = CryptoJS.AES.decrypt(ciphertext, secretKey);
const decryptedMessage = bytes.toString(CryptoJS.enc.Utf8);
console.log("Decrypted:", decryptedMessage);