Marstin
V2EX  ›  问与答

请问用<script>标签使用 vue 的问题

  •  
  •   Marstin · Oct 24, 2019 · 1003 views
    This topic created in 2489 days ago, the information mentioned may be changed or developed.

    请问怎么在一个独立文件中编写 template 和 script ?
    无法使用.vue 文件,.js 文件中也不能写 x-template 标签。
    如果在 html 中使用 x-template,那组件无法在其他页面复用。
    如果在 js 中把 template 内容作为字符串写,代码可读性太差,看起来也非常不直观。

    1 replies    2019-10-24 17:55:26 +08:00
    daguaochengtang
        1
    daguaochengtang  
       Oct 24, 2019
    .vue 文件就是为了解决你说的那两个问题而存在的,但是你又无法使用。也许你可以试一下[JSX]( https://cn.vuejs.org/v2/guide/render-function.html#JSX)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3216 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 12:37 · PVG 20:37 · LAX 05:37 · JFK 08:37
    ♥ Do have faith in what you're doing.