douya2982 2017-09-21 16:40
浏览 116

使用Laravel和Vue无法获得正确的链接

Well I got this problem for a few days now. My issue is: In my .vue page I created the followed link to download a simple PDF file:

<a href= {{ asset('download/form.pdf') }}> Download here. </a>

(The link shows up normally.)

The blade:

@extends('layouts.esic')   
@section('content')
<solicitante></solicitante>
@endsection

But when I click DOWNLOAD HERE I got a error back:

Sorry, the page you are looking for could not be found.

I mean. The file is placed at the public folder and code seems okay. Am I missing something?

Cheers!  

  • 写回答

3条回答 默认 最新

  • dtkl55257 2017-09-21 17:44
    关注

    To make itaccessible from the web, you need to create a symbolic link from public/storage/downlaod to storage/app/public/download

    ln -s /home/vagrant/Code/laravel-project-name/storage/app/public/download /home/vagrant/Code/laravel-project-name/public/storage/download

    评论
  • dqc2017 2017-09-21 19:05
    关注

    if your download folder is located at public folder you can props to import your specific file.

    laravel Blade

     @extends('layouts.esic')   
        @section('content')
        <solicitante :pdf ="{{ json_encode(asset('download/form.pdf')) }}"></solicitante>
        @endsection
    

    component vue. (something like this one)

    <template>
    <a href= {{ pdf }}> Download here. </a>
    </template>
    
    <script>
    export default {
     props: ['pdf'],
    
     ..............
    

    Im not sure if this way are you looking for, (sharing some idea :)

    评论
  • doujuyang1764 2017-09-21 21:21
    关注

    Try this one if you want to just insert a link in vue

    <a v-bind:href="url">{{ url }}</a>
    
    export default {
      data() {
        return  { url: 'http://anywhere.com'  };
      }
    }
    

    Hope this help :)

    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部