Giter Club home page Giter Club logo

vue-sfc-tool's Introduction

VueSFC Tool

Preview

调用[email protected]_browser库 VueSFC Tool 可以将.vue 文件转换为传统多页面模式,方便在维护老旧项目中快速开发,转换代码。

 ...
const compiler = VueTemplateCompiler;
  if (!compiler) {
    throw new Error("VueTemplateCompiler is not defined");
  }
 const parsed = compiler.parseComponent(text);
...

image-20230901103137747

输入:

<template>
  <div class="file" @click="$emit('click', fileInfo)">
    <img :src="imgSrc" class="img" alt="" />
    <div class="name">{{ fileInfo.name }}</div>
  </div>
</template>

<script>
export default {
  props: {
    fileInfo: {
      type: Object,
      default: () => {
        return { name: "湖北", type: "folder" };
      },
    },
  },
  data() {
    return {};
  },
  computed: {
    imgSrc() {
      return `./img/${this.fileInfo.type}.png`;
    },
  },

  watch: {},
  mounted() {},
  created() {},

  methods: {},
};
</script>

<style scoped>
.file {
  width: 100%;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin: 6px;
  padding: 8px;
}
</style>

输出

<script>
  const MyComponent = {
    template: `
<div class="file" @click="$emit('click', fileInfo)">
  <img :src="imgSrc" class="img" alt="" />
  <div class="name">{{ fileInfo.name }}</div>
</div>
`,

    props: {
      fileInfo: {
        type: Object,
        default: () => {
          return { name: "湖北", type: "folder" };
        },
      },
    },
    data() {
      return {};
    },
    computed: {
      imgSrc() {
        return `./img/${this.fileInfo.type}.png`;
      },
    },

    watch: {},
    mounted() {},
    created() {},

    methods: {},
  };
</script>
<style>
  .file {
    width: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin: 6px;
    padding: 8px;
  }
</style>

特性

支持读取本地文件

image-20230901103610706

离线模式

所有资源已经下载本地

image-20230901103707350

部署

使用 es6 的模块化,不支持文件协议打开,需要使用 webserve 打开

vue-sfc-tool's People

Contributors

sweetwisdom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.