main.js中
Vue.prototype.Trim = function(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); }
使用
let str = " 123456789 "
Trim(str) // "123456789"