Refactor from Vue2 to Vue3 (#20044)

Close #19902
This commit is contained in:
André Jaenisch 2022-10-01 16:26:38 +02:00 committed by GitHub
parent 726afe8a9e
commit 04e97b8311
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 384 additions and 606 deletions

View file

@ -1,4 +1,4 @@
import Vue from 'vue';
import {createApp} from 'vue';
import {svgs} from '../svg.js';
export const vueDelimiters = ['${', '}'];
@ -8,13 +8,14 @@ export function initVueEnv() {
if (vueEnvInited) return;
vueEnvInited = true;
const isProd = window.config.runModeIsProd;
Vue.config.productionTip = false;
Vue.config.devtools = !isProd;
// As far as I could tell, this is no longer possible.
// But there seem not to be a guide what to do instead.
// const isProd = window.config.runModeIsProd;
// Vue.config.devtools = !isProd;
}
let vueSvgInited = false;
export function initVueSvg() {
export function initVueSvg(app) {
if (vueSvgInited) return;
vueSvgInited = true;
@ -24,7 +25,7 @@ export function initVueSvg() {
.replace(/height="[0-9]+"/, 'v-bind:height="size"')
.replace(/width="[0-9]+"/, 'v-bind:width="size"');
Vue.component(name, {
app.component(name, {
props: {
size: {
type: String,
@ -42,8 +43,7 @@ export function initVueApp(el, opts = {}) {
}
if (!el) return null;
return new Vue(Object.assign({
el,
delimiters: vueDelimiters,
}, opts));
return createApp(
Object.assign({delimiters: vueDelimiters}, opts)
).mount(el);
}