Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k views
in Technique[技术] by (71.8m points)

有什么组件或模块能把vue节点字符串解析或转换为js对象?

如题,我获取到了vue文件的节点字符串如下所示

<template>
    <div class="content">
        <img class="logo" src="/static/logo.png"></img>
        <div class="text-area">
            <p class="title">这是标题</p>
            <button>提交</button>
        </div>
    </div>
</template>

有没有插件或模块能将上面的字符串转换或解析为如下的js对象

{
    root:{
        tag:'template',
        attr:null,
        child:[{
            tag:'div',
            class:['context'],
            child:[{
                tag:'img'
                class:['logo']
                src:'/static/logo.png'
            },{
                tag:'div'
                class:'text-area'
            }]
        }]
    }
}

并不一定和上面的完全一样,有没有类似的模块?还望各位大佬指点一二。。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

有一个xml2json的,但你这个是特殊需求,可能需要进一步定制。

此外还可以参考 https://www.cnblogs.com/libo0...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...