60 lines
1.2 KiB
HTML
60 lines
1.2 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>Document</title>
|
||
|
<style>
|
||
|
@font-face {
|
||
|
font-family: "水彩字体";
|
||
|
src: url(./字体.woff2);
|
||
|
}
|
||
|
html {
|
||
|
font-family: "水彩字体";
|
||
|
color: salmon;
|
||
|
font-size: 30px;
|
||
|
}
|
||
|
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<div id="app">
|
||
|
The variable named var in the global variable is attached to the window global object
|
||
|
</div>
|
||
|
<script>
|
||
|
|
||
|
let str= "hello 厚度, i o y"
|
||
|
|
||
|
//获取字符串长度
|
||
|
console.log(str.length);
|
||
|
|
||
|
//获取字符串unicode编码
|
||
|
// console.log(str.charCodeAt(0));
|
||
|
|
||
|
//unicode 转字符串
|
||
|
// console.log(String.fromCharCode(1));
|
||
|
|
||
|
//字符串变数值 split()
|
||
|
let name = `章三,李四,王五,赵六`;
|
||
|
console.log(name.split(','));
|
||
|
|
||
|
//正则
|
||
|
|
||
|
let strr = "章三,李四,王五,赵六";
|
||
|
let reg= /,/;
|
||
|
|
||
|
//正则匹配
|
||
|
let b =reg.test(strr);
|
||
|
console.log(b);
|
||
|
|
||
|
//替换
|
||
|
let stt =strr.replace(/,/g,'--');
|
||
|
console.log(stt);
|
||
|
|
||
|
|
||
|
</script>
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|