1 字符串比较

let msg = “hello vue”;
//最后一个是否包含 返回boolbean
console.log(msg.includes(“h”));
//第一个是否包含 返回boolbean
console.log(msg.startsWith(“h”));
//最后一个是否包含 返回boolbean
console.log(msg.endsWith(“h”));

//最后一个是否包含 返回num 0包含 -1不包含
console.log(msg.indexOf(“h”));

2 模板方法使用

//模板方法拼接
let name =“xiaojinlu”;
let url = http://localhost:8081/user/list?name=${name};
console.log(url);

//模板方法计算
let after = 3;
let befer = 5;
let count = ${after+befer};

console.log("aafter + befer = " + count );

//模板方法获取对象信息, 或者调用方法

let person = {name:“xiaojinlu”,age:30,jmup(){
return “fly”;
}}

console.log(name = ${person.name} , age = ${person.age} ,jump method ${person.jmup()} );
console.log(msg);

总结

//这个一定要使用注意注意注意 ``
这个英文模式下打出来
浅谈 es6 字符串使用

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
猜你喜欢
  • 2021-06-04
  • 2021-05-17
  • 2021-12-20
  • 2021-09-14
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案