我开发了一个错误报告程序。整个项目分为两个不同的项目-都有不同的package.json文件-一个用于客户端,在这里我使用Vue.js 2,一个用于由Nodejs 8和Express.js构建的服务器部分。这两个部分将通过REST API进行通信。
要访问仪表板并报告错误,用户必须登录其Google帐户。
到目前为止,我已经在Vuejs中初始化了结构,用户将在其中触发登录事件。我使用的a标签会在signin()按下时触发方法:
<a @click="sign">SIGN IN</a>
// ...
export default {
methods: {
signin() {
// start animation
let loadingInstance = this.$loading({
fullscreen: true,
text: 'Waiting for Google authorization...'
});
// opens the Google sign in window
// when ready stop the loading
loadingInstance.close();
},
},
};
Run Code Online (Sandbox Code Playgroud)
在贝娄,我张贴了我已经注册的路线:
/*
* PACKAGE.JSON IMPORTS
*/
import VueRouter from 'vue-router';
/*
* APP PAGES
*/
import Index from '../pages/index/index.vue';
// The component that only an authorized …Run Code Online (Sandbox Code Playgroud) 我尝试测试以下规则是否适用于字符串:
A-z例如,一个字符串可以是String或CamelCaseString,但既不string也没有Camel-Case-String,也没有String125。不得存在数字和特殊字符。
我在之前的帖子中找到了这个答案。
const isUpperCamelCase = (str) => {
return /\b[A-Z][a-z]*([A-Z][a-z]*)*\b/.test(str)
}
Run Code Online (Sandbox Code Playgroud)
我有以下测试套装试图测试上述功能。不幸的是,并非所有测试都通过:
test('isUpperCamelCase', () => {
expect(isUpperCamelCase('Button')).toBeTruthy()
expect(isUpperCamelCase('GreenButton')).toBeTruthy()
expect(isUpperCamelCase('GreenLargeButton')).toBeTruthy()
expect(isUpperCamelCase('B')).toBeTruthy()
expect(isUpperCamelCase('button')).toBeFalsy()
expect(isUpperCamelCase('buttonCamel')).toBeFalsy()
expect(isUpperCamelCase('Green-Button')).toBeFalsy() // => fail!
expect(isUpperCamelCase('Button125')).toBeFalsy()
expect(isUpperCamelCase('Green_Button')).toBeFalsy()
expect(helpers.isUpperCamelCase('Green+Button')).toBeFalsy() // => fail!
expect(helpers.isUpperCamelCase('green+Button')).toBeFalsy() // => fail!
})
Run Code Online (Sandbox Code Playgroud)
如果我(,)+-在字符串中包含特殊字符,则该函数的计算true结果应为false. 发生这种情况是因为特殊字符之间存在匹配,但这不是我想要的行为。我怎么解决这个问题?
注意:请在您的答案中添加详细说明。谢谢!:)