
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
vue2-migration-helper
Advanced tools
Updates vue2 sfc components to vue3 composition api syntax.
Transforms Vue.js SFCs to composition api syntax.
npm i vue2-migration-helper
# convert all .vue files in source directory and outputs in target directory
vue2-migration-helper --source="source" --target="target"
# displays help
vue2-migration-helper --help
import { vue2MigrationHelper } from 'vue2-migration-helper'
vue2MigrationHelper({
source: 'source/',
target: 'target/',
})
setup
method
props
and context
argumentsimports
data
properties
data
variable using reactive
ref
computed
syntax
computed
watch
syntax
methods
directly into setup
methods
into the setup bodyref
usage
templateRef
using ref(null)
props
syntaxlifecycle
hooks and remove deperecated lifecycle hooks
setup
method.hooks
into the setup
methodcomponent
registrationthis
usage with new context
parameter for $events etc
this
keyword usage as this no longer refers to vue component itself.missing something?
For a Vue.js SFC (single file component) like this:
import SomeComponent from './SomeComponent'
const zero = {}
export default {
props: {
title: String,
likes: Number,
callback: Function,
},
components: {
SomeComponent,
},
data() {
return {
one: true,
two: 2,
three: 'three',
}
},
watch: {
one(val) {
console.log(val)
},
two: (val) => {
console.log(val)
},
three: function (a, b) {
console.log(a, b)
},
},
computed: {
oneComputed() {
return !this.one
},
twoComputed: () => {
return !this.one
},
threeComputed: function () {
return !this.one
},
},
created() {
console.log('created')
},
mounted() {
console.log('mounted')
},
methods: {
...[
function fourMethod() {
console.log('fourMethod')
},
function fiveMethod() {
console.log('fiveMethod')
},
],
oneMethod() {
const html = this.$refs.templateRef.innerHTML
console.log('oneMethod')
console.log(this.oneComputed)
},
twoMethod: function () {
this.$refs.templateRef.innerHTML = 'html'
console.log('twoMethod')
console.log(this.twoComputed)
this.oneMethod()
console.log(this.$router)
},
threeMethod: () => {
console.log('threeMethod')
console.log(this.threeComputed)
this.twoMethod()
console.log(this.$store)
},
},
}
this script generates Vue SFC using composition API:
import {
ref,
reacted,
toRefs,
watch,
computed,
onCreated,
onMounted,
} from 'vue'
import SomeComponent from './SomeComponent'
const zero = {}
export default {
components: {
SomeComponent,
},
props: {
title: String,
likes: Number,
callback: Function,
},
setup(props, context) {
const data = reactive({
one: true,
two: 2,
three: 'three',
})
const templateRef = ref(null)
watch(three, (a, b) => {
console.log(a, b)
})
watch(two, (val) => {
console.log(val)
})
watch(one, (val) => {
console.log(val)
})
const oneComputed = computed(() => {
return !data.one
})
const twoComputed = computed(() => {
return data.two + 5
})
const threeComputed = computed(() => {
return data.three.toUpperCase()
})
;(() => {
console.log('created')
})()
onMounted(() => {
console.log('mounted')
})
function fourMethod() {
console.log('fourMethod')
}
function fiveMethod() {
console.log('fiveMethod')
}
function oneMethod() {
const html = templateRef.innerHTML
console.log('oneMethod')
console.log(oneComputed)
console.log(context.$data)
}
function twoMethod() {
templateRef.innerHTML = 'html'
console.log('twoMethod')
console.log(twoComputed)
oneMethod()
console.log(context.$router)
}
function threeMethod() {
console.log('threeMethod')
console.log(threeComputed)
twoMethod()
console.log(fourMethod)
console.log(context.$store)
}
return {
...ref(data),
oneComputed,
twoComputed,
threeComputed,
fourMethod,
fiveMethod,
oneMethod,
twoMethod,
threeMethod,
templateRef,
}
},
}
FAQs
Updates vue2 sfc components to vue3 composition api syntax.
The npm package vue2-migration-helper receives a total of 2 weekly downloads. As such, vue2-migration-helper popularity was classified as not popular.
We found that vue2-migration-helper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.