我正在尝试转换一个数字数组,使每个数字只有一个非零数字.所以基本上
"7970521.5544"
Run Code Online (Sandbox Code Playgroud)
会给我的
["7000000", "900000", "70000", "500", "20", "1", ".5", ".05", ".004", ".0004"]
Run Code Online (Sandbox Code Playgroud)
我试过了:
var j = "7970521.5544"
var k =j.replace('.','')
var result = k.split('')
for (var i = 0; i < result.length; i++) {
console.log(parseFloat(Math.round(result[i] * 10000) /10).toFixed(10))
}
Run Code Online (Sandbox Code Playgroud)
任何想法,我不知道从哪里开始?
我目前正在使用 vite 设置 vue 2 应用程序。
我收到这个错误。我想在 vue 2 中设置该项目。我知道它是为 vue 3 构建的,但是我缺少什么吗?
维特配置
import { minifyHtml, injectHtml } from 'vite-plugin-html'
import legacy from '@vitejs/plugin-legacy'
const path = require('path')
const { createVuePlugin } = require('vite-plugin-vue2')
module.exports = {
plugins: [
createVuePlugin(),
minifyHtml(),
injectHtml({
injectData: {
title: 'ProjectName',
description: 'A single page application created using Vue.js'
}
}),
legacy({
targets: ['ie >= 11'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime']
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, '/src'),
'~bootstrap': 'bootstrap'
}
},
css: {
preprocessorOptions: …Run Code Online (Sandbox Code Playgroud) 我试图在他们获得401后注销我的用户.我正在使用axios从api返回数据
我环顾四周,找到了相同的axios.interceptors.response
axios.interceptors.response.use(
response => response,
error => {
const {status} = error.response;
if (status === 401 ) {
store.dispatch('snackBar', snackbarObj)
}
return Promise.reject(error);
}
)
Run Code Online (Sandbox Code Playgroud)
看来我的错误.回复是未定义的.我不确定有什么问题?有任何想法吗?
我最近一直在向我的项目添加一些单元测试,并且想知道是否可以将这些单元测试添加到我的纱线运行构建过程中。或者创建一个 bash 脚本来运行两个 cmds 会更好,比如 yarn run unit 然后 yarn run build。
我该怎么办?
我正在使用 VueJs cli 和 Jest 进行单元测试
javascript ×3
vue.js ×3
algorithm ×1
arrays ×1
axios ×1
interceptor ×1
jestjs ×1
math ×1
split ×1
vite ×1