2024-08-05 11:36:27 +00:00
|
|
|
import { createApp } from 'vue'
|
|
|
|
import './style.css'
|
|
|
|
import App from './App.vue'
|
2024-08-06 11:32:06 +00:00
|
|
|
import '@unocss/reset/sanitize/sanitize.css'
|
|
|
|
import '@unocss/reset/sanitize/assets.css'
|
|
|
|
import 'virtual:uno.css'
|
2024-08-12 07:20:28 +00:00
|
|
|
import "vant/es/image-preview/style";
|
2024-08-09 05:40:02 +00:00
|
|
|
import { ImagePreview } from 'vant';
|
2024-08-12 11:55:59 +00:00
|
|
|
import Vconsole from 'vconsole'
|
|
|
|
new Vconsole()
|
2024-08-05 11:36:27 +00:00
|
|
|
import router from "./router/index.js";
|
|
|
|
const app = createApp(App);
|
|
|
|
app.use(router);
|
2024-08-09 05:40:02 +00:00
|
|
|
app.use(ImagePreview);
|
|
|
|
|
2024-08-07 12:00:54 +00:00
|
|
|
app.directive('no-space', {
|
|
|
|
mounted(el) {
|
|
|
|
el.addEventListener('input', (e) => {
|
|
|
|
const originalValue = e.target.value;
|
|
|
|
const newValue = originalValue.replace(/\s/g, '');
|
|
|
|
if (originalValue !== newValue) {
|
|
|
|
e.target.value = newValue;
|
|
|
|
e.target.dispatchEvent(new Event('input'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
2024-08-12 11:55:59 +00:00
|
|
|
app.directive('number-only', {
|
|
|
|
mounted(el) {
|
|
|
|
el.addEventListener('input', (event) => {
|
|
|
|
const { value } = event.target;
|
|
|
|
// 使用正则表达式限制输入格式
|
|
|
|
event.target.value = value.replace(/[^0-9.]/g, ''); // 只保留数字和小数点
|
|
|
|
if (event.target.value.indexOf('.') !== -1) {
|
|
|
|
// 如果已经包含小数点
|
|
|
|
const parts = event.target.value.split('.');
|
|
|
|
event.target.value = `${parts[0]}.${parts[1].slice(0, 1)}`; // 只保留一位小数
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2024-08-05 11:36:27 +00:00
|
|
|
app.mount('#app');
|