parcel vue 简单使用

1.安装依赖
yarn global add parcel-bundler
yarn add babel-preset-env --dev
yarn add parcel-plugin-vue --dev
yarn add babel-plugin-transform-runtime --dev
yarn add babel-preset-es2015 --dev
yarn add parcel-bundler --dev
yarn add vuejs
2. 项目结构
├── appdemo.js
├── app.vue
├── index.html
├── index.js
├── package.json
└── yarn.lock

appdemo.js
export const  dalong ={
 
  demo(){
   return "dalong demo"
 }
}

app.vue
<template>
   <div>
    {{info}}
   <button @click="demo">click demo</button>
   </div>
</template>
<script>
import {dalong} from "./appdemo";
 export default {
  data(){
   return {
    info:dalong.demo()
   }
 },
 methods:{
   demo(){
    alert(dalong.demo())
   }
 }
 }
</script>

index.html
<html>
<body>
<h1>this is dalong demo</h1>
<div id="app">
</div>
<script src="./index.js"></script>
</body>
</html

index.js
import App from "./app.vue";
import Vue from "vue";
new Vue({

 render: h =>h(App),
 el:"#app"
})

package.json
{
  "name": "vuedemo",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-es2015": "^6.24.1",
    "parcel-bundler": "^1.3.1",
    "parcel-plugin-vue": "^1.4.0"
  },
  "dependencies": {
    "vuejs": "^2.0.19"
  }
}
3. 代码 说明
代码比较简单,主要是parcel vue 插件配置
4. 运行
parcel index.js
运行效果
 
5. 生产构建
parcel build index.html  可以看到代码都是压缩过的
6. 参考资料
https://www.npmjs.com/package/parcel-plugin-vue
https://parceljs.org/

posted on   荣锋亮  阅读(439)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2014-12-31 Web Pages razor 学习

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示