问题:有一些日语文字だめ正确显示
原因:是字体问题,现在用的字体不能支持某些字符的显示
解决:添加日文输入法
问题:日文输入法会影响其他的语言下的样式
解决:根据系统当前语言切换不同的字体样式
实现1:js中拿到当前语言,动态require文件
问题:本地测试ok,但是线上环境无论何时都会加载文件,导致一直是日语的样式
原因:暂时没搞明白
实现2:js中拿到当前语言,判断为日语时加载css脚本
const JA = `
body {
font-family: "Monospaced Number", "Microsoft YaHei", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif, "メイリオ", "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Helvetica, Arial !important;
}
.ant-tabs, .ant-table, .ant-form-item, .ant-collapse, .ant-input, .ant-pagination, .ant-select, .ant-modal, .ant-form-item {
font-family: "Monospaced Number", "Microsoft YaHei", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif, "メイリオ", "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Helvetica, Arial !important;
}
input, button, select, optgroup, textarea {
font-family: "Monospaced Number", "Microsoft YaHei", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif, "メイリオ", "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Helvetica, Arial !important;
}
`;
export { JA };
import { JA } from './assets/styles/StyleStr';
const getCurrentFont = () => {
const curLanguage = getCurrentLanguage();
if ( curLanguage === 'jp_JP' ) {
loadStyleString(JA);
}
};
/**
* 动态加载css脚本
* @param {string} cssText css样式
*/
function loadStyleString(cssText) {
const style = document.createElement("style");
style.type = "text/css";
// firefox、safari、chrome和Opera
style.appendChild(document.createTextNode(cssText));
document.getElementsByTagName("head")[0].appendChild(style);
}