Search code examples
vue.jsrazor

How use 'v-for' object inside razor element in vue js


In my code there is a loop and inside that I have a <a> tag ; I want to generate its link by using a server-base code function; part of my code:

                <div v-for="file in fileList">
                    <div class="badge">
                        <a href="@Web.CreateDownloadLink(file,false)" target="_blank"><i class="fa fa-cloud-download"></i> {{file.name}}</a>
                    </div>
                </div>

Is there any way to do this?


Solution

  • As you may know server code runs before the javascript, javascript run on the client browser. So when your server-based code runs it sees all of the javascript code as a static text.

    A possible solutions here: is you do a normal javascript function that calls a RESTful API which create a link and send it back.