代碼塊
- 數(shù)字輸入框 文字偏左
::v-deep .el-input-number .el-input__inner {
text-align: left;
}
- 替換按鈕圖標
::v-deep .el-icon-edit {
background: url('~@/assets/images/ai/verify_edit.svg') center
no-repeat; // 注意此處的url,在這里引入自己的圖片
font-size: 12px;
background-size: cover;
}
::v-deep .el-icon-edit:before {
content: '替';
font-size: 12px;
visibility: hidden;
}
- 確認功能
submitToPerson(item) {
console.log(":" + "->" + JSON.stringify(item));
const wayKeyWord = ''
let params = { audioId: item.id };
statusChange(item.id, params)
.then((res) => {
console.log("click_changeState res=>" + JSON.stringify(res));
if (res.data) {
this.$message.success(`${wayKeyWord}成功!`);
} else {
this.$message.warning(`${wayKeyWord}失??!`);
}
setTimeout(() => {
this.getList();
}, 20);
})
.catch((error) => {
console.error("->", JSON.stringify(error));
this.$message.warning(`${wayKeyWord}失敗!`);
});
},
- 下載文件
const blob = new Blob([file.data], {type: file.headers['content-type']});
let downloadElement = document.createElement('a');
let href = window.URL.createObjectURL(blob);
downloadElement.href = href;
downloadElement.download = `xxx${Date.now()}`;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
window.URL.revokeObjectURL(href);
查找數(shù)組
- Array.prototype.includes()
includes() 方法用來判斷一個數(shù)組是否包含一個指定的值,如果包含則返回 true,否則返回 false。
- Array.prototype.indexOf()
indexOf() 方法返回指定元素在數(shù)組中的第一個索引,如果不存在,則返回-1。
- Array.prototype.some()
some() 方法測試數(shù)組中是不是至少有1個元素通過了被提供的函數(shù)測試。它返回的是一個 Boolean 類型的值。
[2, 5, 8, 1, 4].some(x => x > 10); // false
- Array.prototype.every()
every() 方法測試一個數(shù)組內(nèi)的所有元素是否都能通過某個指定函數(shù)的測試。它返回一個布爾值。
function isBigEnough(element, index, array) {
return element >= 10;
}
[12, 5, 8, 130, 44].every(everyItem => everyItem >= 10); // false
[12, 54, 18, 130, 44].every(isBigEnough); // true
- Array.prototype.filter()
filter() 方法創(chuàng)建一個新數(shù)組, 包含通過所提供函數(shù)實現(xiàn)的測試的所有元素。
function isBigEnough(element) {
return element >= 10;
}
var filtered = [12, 5, 8, 130, 35].filter(filterItem => filterItem >=10);
// filtered is [12, 130, 35]
- Array.prototype.find()
find() 方法返回數(shù)組中滿足提供的測試函數(shù)的第一個元素的值。否則返回 undefined。
var inventory = [
{name: 'apples', quantity: 2},
{name: 'bananas', quantity: 0},
{name: 'orange', quantity: 5}
];
function findOranges(fruit) {
return fruit.name === 'orange';
}
inventory.find(findItem => findItem.name === 'orange'); // { name: 'orange', quantity: 5 }
- Array.prototype.findIndex()
findIndex() 方法返回數(shù)組中滿足提供的測試函數(shù)的第一個元素的索引。若沒有找到對應元素則返回-1。
var inventory = [
{name: 'apple', quantity: 2},
{name: 'banana', quantity: 0},
{name: 'orange', quantity: 5}
];
function findOrange(fruit) {
return fruit.name === 'orange';
}
console.log(inventory.findIndex(findIndexItem => findIndexItem.name === 'orange'));
// { name: 'orange', quantity: 5 }
vue中的css樣式:文字超過一行的部分用省略號表示
- 替換按鈕圖標
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;//超過行數(shù)
overflow: hidden;
word-break: break-all;