1

I want to modify(add or remove node) the parsed ast return by the parse function of @vue/compiler-dom.

I would expect there is a visit method of the ast object, but I can't find one.

Here is the pseudo code what I would expect:

foo.vue

<template>
  <div>foo</div>
  <div>
    <a href="">
      bar
      <img src="" alt="">
    </a>
  </div>
  <div @click="onClick">foobar</div>
</template>

<script lang="js">
export default {
  methods: {
    onClick () {},
  },
}
</script>
import { parse } from '@vue/compiler-dom';

const ast = parse(content of foo.vue)

ast.visit(...)
4

0 回答 0