jsv-compiler
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

.js 文件中使用 vue3 模板语法

使用

1. 创建vue3项目

create-vite-app <your projectname>

2. 安装依赖包

npm i -D jsv-compiler

3. 配置插件

文件: vite.config.js

import {jsvPlugin} from 'jsv-compiler'

export default {
  configureServer: [jsvPlugin]
}

4. 使用示例

import { reactive } from "vue";

export default {
	name: "App",
	setup() {
		let state = reactive({ 
			title: 'jsv-compiler',
			count: 0 
		});

		function handleClick() {
			state.count++;
		}

		let Title = `<template><h1>hello {{state.title}}</h1></template>`
		
		return (`
			<template>
				<Title />
				<div>{{ state.count }}</div>
				<button v-on:Click="handleClick">点击加1</button>
			</template>
			`)
	},
};

5. 语法高亮

在vscode中下载插件: jsv

Readme

Keywords

Package Sidebar

Install

npm i jsv-compiler

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

6.26 MB

Total Files

22

Last publish

Collaborators

  • ruige24601