1.
&::placeholder {
color: #ffffff !important;
text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
font-size: 14px;
}
2.重写ant design中的icon
<Icon src={require('@/static/images/download.svg')} type="svg" width="18px" height="18px" />
3.使用正则表达式匹配搜索关键字中的字,并且给匹配的颜色标红
dangerouslySetInnerHTML={{ __html: getHighlightText(item.serviceName, searchText, 'span')}}
export const getHighlightText = (content = '', keyword = '', tagName = 'span') => {
// 高亮关键词
if (!content) {
return content;
}
const val = `<${tagName} style="color:red;">${keyword}</${tagName}>`;
const regS = new RegExp(keyword, 'gi');
return content.replace(regS, val);
};
4.button按钮进行文件下载
使用 Blob 和 msSaveBlob 以本地方式保存文件
callback: (file) => {
if (file && file.blob) {
file.blob().then((blob) => {
let contentDisposition = file.headers.get('Content-Disposition');
const str = contentDisposition.match(/filename="(.+)"/)[1];
filename = decodeURI(str);
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, fileName);
} else {
const a = document.createElement('a');
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.style.display = 'none';
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}
});
}
}
return io.get(`/dl/data/api/open/dataservice/download-docx${params}`, {
headers: {
Accept: 'application/octet-stream'
}
});