js中用于判断字符串是否以指定字符串开头的startWith()方法

js中startWith()方法用于检测字符串是否以指定的字符串开头

'hello world'.startsWith('hello')

在vue中可以使用此方法检查路由地址

import {useRoute} from 'vue-router';
const route = useRoute();
let path= route.path;
path.startWith('/login');
posted @ 2022-02-27 13:41  QTDD  阅读(942)  评论(0)    收藏  举报