A Vue CLI plugin to generate components or pages.
- SFC(.vue)
- TSX(.tsx)
- JSX(.jsx)
- CSS(.css)
- SCSS(.scss)
- Sass(.sass)
- Less(.less)
- Stylus(.styl)
vue add vue-cli-plugin-generators
or
yarn add vue-cli-plugin-generators -D
vue invoke generators
yarn add-component
yarn add-page
/**
* @file HelloWorld
*/
import { defineComponent, ref } from 'vue';
import './index.css';
export default defineComponent({
name: 'HelloWorld',
setup() {
const str = ref('World');
/**
* @function ChangeStr
* @description handle str change
*/
const handleStrChange = () => {
str.value = 'Vue';
};
return {
str,
handleStrChange
};
},
render() {
const { str, handleStrChange } = this;
return (
<div className="HelloWorld_container">
<h1>Hello{str}!</h1>
<button onClick={handleStrChange}>Change Hello</button>
</div>
);
}
});
<template>
<div class="HelloWorld_container">
<h1>Hello{{ str }}</h1>
<button @click="handleStrChange">Change Hello</button>
</div>
</template>
<script>
/**
* @file HelloWorld
*/
import { defineComponent, ref } from 'vue';
export default defineComponent({
name: 'HelloWorld',
setup() {
const str = ref('World');
/**
* @function ChangeStr
* @description handle str change
*/
const handleStrChange = () => {
str.value = 'Vue';
};
return {
str,
handleStrChange
};
}
});
</script>
<style>
</style>