【问题标题】:Using a blade file for a template?使用刀片文件作为模板?
【发布时间】:2017-03-29 11:20:26
【问题描述】:

我有一个刀片文件,我希望将其用作 vue 组件。所以在 .vue 文件中,我通常会将其编码为:

<template>
....
</tempalte>
....rest of vue file

但是如何将刀片文件用于模板?

【问题讨论】:

    标签: laravel laravel-5 vue.js vuejs2 laravel-5.4


    【解决方案1】:

    您可以将 html 放入您的 vue-component 文件中,例如:

    <template>
    ...put your html here
    </tempalte>
    

    然后在刀片文件中插入vue组件,如

    @extends('layouts.app')
      <vue-component> </vue-component>
    @section('content')
    

    【讨论】:

    • 谢谢,但不回答问题,我不想要 vue 文件中的 html。
    • 哦!对不起。你的问题中没有说明这一点。我不确定是否支持。
    【解决方案2】:

    您可以在 vue 文件中使用slot 来插入从刀片视图传递过来的 html。

    刀片文件:

    <vue-component>All your html to be passed goes here</vue-component>
    

    Vue 文件:

    <template>
        <slot></slot>
    </template>
    

    您可以在单槽here 的官方文档中了解更多信息。

    【讨论】:

    • 谢谢,但不起作用,vue 文件未附加到 html 组件。
    • 您是否在控制台/终端上遇到任何错误?我一直在使用类似的代码将一些渲染的 html 从刀片模板传递到 vue,它可以工作。
    • 是的,只是在vue组件上找不到方法的错误。
    • 您能否用您尝试过的方法更新问题?我无法弄清楚你指的是什么方法。
    猜你喜欢
    • 2016-03-18
    • 2020-04-21
    • 2014-11-15
    • 2014-03-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-24
    • 2016-03-11
    • 2013-06-04
    相关资源
    最近更新 更多