将原始 html 从 Vue 返回到 Laravel Blade

编程入门 行业动态 更新时间:2024-10-11 01:17:05
本文介绍了将原始 html 从 Vue 返回到 Laravel Blade的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试将表单输入预览到另一个 div 作为 html markdown.

{!!表单::打开(['route' => 'post.create']) !!}{{ Form::text('title', 'title', ['class' => 'form-control']) }}{{ Form::hidden('category_id', $category->id) }}{{ Form::textarea('body', 'body', ['class' => 'form-control', 'v-model' => 'input']) }}<div><?php echo '{{{ output }}}';?></div>{{ Form::submit('send', ['class' =>'btn btn-sm btn-default btn-block']) }}{!!表单::关闭() !!}

app.js 上:

const app = new Vue({el: '#form',数据: {输入: '',输出: ''},手表: {输入:函数(val){this.output = 标记(val);}}});

@{{{ output }}}} 返回相同的结果,即控制台上有错误的空白页:

- 无效表达式:意外标记 ) 中_s({输出)+"}"原始表达式:{{{ 输出}}}

解决方案

如果您的输出是原始 html,请使用:

<div v-html="output"></div>

I am trying to preview input of form to another div as html markdown.

<div class="form-group" id="form">
  {!! Form::open(['route' => 'post.create']) !!}
    {{ Form::text('title', 'title', ['class' => 'form-control']) }}
    {{ Form::hidden('category_id', $category->id) }}
    {{ Form::textarea('body', 'body', ['class' => 'form-control', 'v-model' => 'input']) }}
    <div><?php echo '{{{ output }}}'; ?></div>
    {{ Form::submit('send', ['class' => 'btn btn-sm btn-default btn-block']) }}
  {!! Form::close() !!}
</div>

On app.js:

const app = new Vue({
    el: '#form',
    data: {
      input: '',
      output: ''
    },
    watch: {
      input: function(val) {
        this.output = marked(val);
      }
    }
});

@{{{ output }}}} returns the same result which is blank page with error on console:

- invalid expression: Unexpected token ) in

_s({ output)+"}"

Raw expression: {{{ output }}}

解决方案

If your output is raw html use:

<div v-html="output"></div>

这篇关于将原始 html 从 Vue 返回到 Laravel Blade的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 01:20:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145638.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:原始   html   Vue   Laravel   Blade

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!