Why is mixing Razor Pages and VueJs a bad thing?

Joel Pinto Ribeiro :

I'm trying to set up a .NET core project using Razor Pages and include vueJs inside the razor page for all my logic.

Something like this:

@{
    ViewData["Title"] = "VueJs With Razor";
}
<h2>@ViewData["Title"].</h2>

<div id="app">
   <span>{{ message }}</span>
</div>

<script>
     new Vue({
        el: '#app',
        data: {
          message : 'Hello vue.js'
        }
    })
</script>

I have read that mixing Vue and Razor pages is a bad practice, and one should use Razor OR Vue.

Why is this?

bbsimonbb :

You can do this. Sometimes you're obliged to do it, if, like us, you're migrating an existing code base and you can't convert everything at once. And as Ron C says, it works well.

If you're starting a new project, you have the luxury of choosing. Reasons for favouring an SPA and no Razor would be...

  • Reactivity. SPA apps generally feel (much) more reactive. Initial renders are often served from cache, before the data arrives. On first load, all resources arrive in a bundle, in one request-response. There's no, or much less, request chaining.

  • Workflow. Webpack, bundling and hot reloads are great. You get production builds, with minification, compilation of Vue render functions, elimination of 404 style errors, js syntax errors are trapped. The cycle from introducing an error to discovering it is greatly reduced for many errors.

  • SPA universe. Routing, Vuex, this really is the way of the future.

  • Purity. Razor and Vue do similar things at the end of the day. If you mix them, you may have a hard time keeping your head straight.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why mixing interpolation and expressions is bad practice

分類Dev

ASP.NET Razor Pages - Conditional redirection

分類Dev

How to collapse solution explorer view of razor pages?

分類Dev

Blazor Security - Razor Pages custom authentication/security

分類Dev

.NET Core Unit Test Razor Pages RedirectToPage()

分類Dev

c#Razor Pages Select Tag Helper

分類Dev

Why is it bad to defragment an SSD?

分類Dev

Bad way of loading pages with react-loadable

分類Dev

RE: CRUD operations. Is it pulling more data than is needed a bad thing?

分類Dev

Razor Pages AJAX URLIDパラメーター

分類Dev

razor pages, how to passing json serialized string into model property

分類Dev

Printing PDF in ASP.net core 3.1 Razor Pages

分類Dev

Why is >>= faster than concatMap when they ought to be the same thing?

分類Dev

why is in Vuejs the toggle functionality not working

分類Dev

Why in vuejs app prefer-const rule in vuejs app is not disabled?

分類Dev

Why are there two functions which do the exact same thing? Why must be invoked differently in Kotlin?

分類Dev

Appending to slice bad performance.. why?

分類Dev

Why is it bad to call a function in the condition of a for loop?

分類Dev

Why do fonts look bad in some applications?

分類Dev

why this code is not loading pages ajax jquery

分類Dev

Why does `this` inside filter() gets undefined in VueJS?

分類Dev

ASP.net razor pages and multi-select, posting all items in select

分類Dev

ASP.NET Core Razor Pages | can partial views have page models

分類Dev

How to increment and use a value in Jquery and Razor pages, in ASP.net core 2.0

分類Dev

ModelState.AddModelError doesn't show any message in asp.net.core RAZOR pages

分類Dev

ModelState.AddModelError doesn't show any message in asp.net.core RAZOR pages

分類Dev

Asp.net core - razor pages (.cshtml) vs angular 2+

分類Dev

Asp .Net Core 2.2 Razor Pages Ajax CallPostが機能しない

分類Dev

Blazor-Server-Appでcshtml(Razor Pages)を使用する方法

Related 関連記事

  1. 1

    Why mixing interpolation and expressions is bad practice

  2. 2

    ASP.NET Razor Pages - Conditional redirection

  3. 3

    How to collapse solution explorer view of razor pages?

  4. 4

    Blazor Security - Razor Pages custom authentication/security

  5. 5

    .NET Core Unit Test Razor Pages RedirectToPage()

  6. 6

    c#Razor Pages Select Tag Helper

  7. 7

    Why is it bad to defragment an SSD?

  8. 8

    Bad way of loading pages with react-loadable

  9. 9

    RE: CRUD operations. Is it pulling more data than is needed a bad thing?

  10. 10

    Razor Pages AJAX URLIDパラメーター

  11. 11

    razor pages, how to passing json serialized string into model property

  12. 12

    Printing PDF in ASP.net core 3.1 Razor Pages

  13. 13

    Why is >>= faster than concatMap when they ought to be the same thing?

  14. 14

    why is in Vuejs the toggle functionality not working

  15. 15

    Why in vuejs app prefer-const rule in vuejs app is not disabled?

  16. 16

    Why are there two functions which do the exact same thing? Why must be invoked differently in Kotlin?

  17. 17

    Appending to slice bad performance.. why?

  18. 18

    Why is it bad to call a function in the condition of a for loop?

  19. 19

    Why do fonts look bad in some applications?

  20. 20

    why this code is not loading pages ajax jquery

  21. 21

    Why does `this` inside filter() gets undefined in VueJS?

  22. 22

    ASP.net razor pages and multi-select, posting all items in select

  23. 23

    ASP.NET Core Razor Pages | can partial views have page models

  24. 24

    How to increment and use a value in Jquery and Razor pages, in ASP.net core 2.0

  25. 25

    ModelState.AddModelError doesn't show any message in asp.net.core RAZOR pages

  26. 26

    ModelState.AddModelError doesn't show any message in asp.net.core RAZOR pages

  27. 27

    Asp.net core - razor pages (.cshtml) vs angular 2+

  28. 28

    Asp .Net Core 2.2 Razor Pages Ajax CallPostが機能しない

  29. 29

    Blazor-Server-Appでcshtml(Razor Pages)を使用する方法

ホットタグ

アーカイブ