|
1 | 1 | # Vue.js ASP.NET Web Forms Helpers
|
2 | 2 |
|
3 |
| -This library (.NET Framework 4.5) contains 4 ASP.NET Web Forms controls to simplify integrating Vue.js with ASP.NET Web Forms. |
| 3 | +This library (.NET Framework 4.5) contains 3 ASP.NET Web Forms controls to simplify integrating Vue.js with ASP.NET Web Forms. |
4 | 4 |
|
5 |
| -Each control can render for Vue.js or for the [Vue Light .NET Compiler](https://github.com/jesperhoy/VueLight) (no reactivity) by setting the "VueLight" attribute (false/true). |
| 5 | +The **Component** and **App** controls can either render for Vue.js or for the [Vue Light .NET Compiler](https://github.com/jesperhoy/VueLight) (no reactivity) by setting the "VueLight" attribute (false/true). |
6 | 6 |
|
7 | 7 | ## How to use
|
8 | 8 |
|
9 | 9 | [Download the "VueJSWebForms.dll" file](https://github.com/jesperhoy/VueJSWebForms/releases) and drop this into your ASP.NET web site's "bin" folder.
|
10 | 10 |
|
11 | 11 | You can reference the assembly in a Web Forms page like this:
|
12 | 12 |
|
13 |
| - <%@ Register Assembly="VueJSWebForms" Namespace="VueJSWebForms" TagPrefix="vwf" %> |
| 13 | + <%@ Register Assembly="VueJSWebForms" Namespace="VueJSWebForms" TagPrefix="vue" %> |
14 | 14 |
|
15 |
| -And then instantiate a control (in this case "Component") like this: |
| 15 | +And then use the controls like this: |
16 | 16 |
|
17 |
| - <vwf:Component id="thing" params="year,color" runat="server"> |
18 |
| - ...Vue.js template... |
19 |
| - </vwf:/Component> |
| 17 | + <vue:Component name="car" props="make,year" runat="server"> |
| 18 | + <li>This {{make}} is {{(new Date()).getFullYear() - year}} years old.</li> |
| 19 | + </vue:Component> |
20 | 20 |
|
21 |
| -And then use an instance of that component in another Vue.js template: |
| 21 | + <vue:App datajs="[{Make:'Buick',Year:2001},{Make:'Pontiac',Year:1998}]" runat="server" > |
| 22 | + <ul> |
| 23 | + <car v-for="car in cars" :make="car.Make" :year="car.Year" /> |
| 24 | + </ul> |
| 25 | + </vue:App> |
22 | 26 |
|
23 |
| - <thing year="2018" color="blue" /> |
24 | 27 |
|
25 | 28 |
|
26 | 29 | ## ASP.NET Web Forms controls
|
27 | 30 |
|
28 |
| -- **Render** |
| 31 | +- **Component** |
29 | 32 |
|
30 |
| - Used to render the results of a Vue.js template using global variables. |
| 33 | + Makes it easy to render a Vue.js component for re-use in a Vue.js application or in other Vue.js components. |
31 | 34 |
|
32 | 35 | Parameters:
|
33 |
| - - `DataJS` - The Vue.js "data" property. A string with a JSON data object (or JavaScript) to use for rendering. |
34 |
| - - `VueLight` (true/false) - If the template should be compiled and rendered by the Vue Light server side compiler. |
| 36 | + - `File` - virtual path of a .vue file (for example "~/components/list1.vue"). If not specified, the content of the control is used as the Vue.js template instead. |
| 37 | + - `Name` - the name of the component (tag-name in app/other components). If not specified and `File` is, the file name (without path / suffix) will be used as the component name. |
| 38 | + - `Props` - a comma separated list of property names for the component (not used when `File` is specified). |
35 | 39 | - `RenderTemplate` (true/false) - If the raw template should be rendered (in a `<script type="x-template">` tag). Not technically necessary and makes output larger, but helpful for debugging if template is generated dynamically.
|
| 40 | + - `VueLight` (true/false) - If the template should be compiled and rendered by the Vue Light server side compiler (no reactivity). |
36 | 41 |
|
37 |
| - Examples of use in a Web Forms page: |
38 |
| - - [Rendered with Vue Light .NET Compiler](sample-web-site/sample-vuelight.aspx) |
39 |
| - - [Rendered with Vue.js](sample-web-site/sample-vuejs.aspx) |
40 |
| - |
41 |
| -- **Component** |
| 42 | +- **App** |
42 | 43 |
|
43 |
| - Makes it easy to render a simple Vue.js component for re-use in Vue.js application or in other Vue.js components. |
| 44 | + Used to render the results of a Vue.js template. |
44 | 45 |
|
45 | 46 | Parameters:
|
46 |
| - - `ID` - the name of the component. |
47 |
| - - `Props` - a comma separated list of property names for the component. |
48 |
| - - `VueLight` (true/false) - If the template should be compiled and rendered by the Vue Light server side compiler. |
| 47 | + - `File` - virtual path of a .vue file (for example "~/components/list1.vue"). If not specified, the content of the control is used as the Vue.js template instead. |
| 48 | + - `DataJS` - The Vue.js "data" property. A string with a JSON data object (or JavaScript) to use for rendering. |
| 49 | + - `Name` - the name of the Vue.js app variable. Defaults to "app". |
49 | 50 | - `RenderTemplate` (true/false) - If the raw template should be rendered (in a `<script type="x-template">` tag). Not technically necessary and makes output larger, but helpful for debugging if template is generated dynamically.
|
| 51 | + - `VueLight` (true/false) - If the template should be compiled and rendered by the Vue Light server side compiler (no reactivity). |
50 | 52 |
|
51 |
| - Examples of use in a Web Forms page: |
52 |
| - - [Rendered with Vue Light .NET Compiler](sample-web-site/sample-vuelight.aspx) |
53 |
| - - [Rendered with Vue.js](sample-web-site/sample-vuejs.aspx) |
| 53 | + |
| 54 | +- **Template** |
54 | 55 |
|
55 |
| -- **FileComponent** |
| 56 | + Used to render HTML in a `<script type="x-template">` tag. |
56 | 57 |
|
57 |
| - Use to render a Vus.js component from a .vue file for re-use in Vue.js application or in other Vue.js components. |
| 58 | + The only purpose of this is to get HTML syntax highlighting and intellisense in the HTML editor in Visual Studio. This is not really specific to Vue.js in any way, but is convenient when authoring more complex Vue.js applications / components. |
58 | 59 |
|
59 | 60 | Parameters:
|
60 |
| - - `File` - virtual path of the .vue file (for example "~/components/list1.vue"). |
61 |
| - - `ID` - the name of the component. |
62 |
| - - `VueLight` (true/false) - If the template should be compiled and rendered by the Vue Light server side compiler. |
63 |
| - - `RenderTemplate` (true/false) - If the raw template should be rendered (in a `<script type="x-template">` tag). Not technically necessary and makes output larger, but helpful for debugging. |
| 61 | + - `ID` - will be rendered as the ID for the script tag. |
64 | 62 |
|
65 |
| - [Example of use in a Web Forms page](sample-web-site/sample-vue-file.aspx) |
66 | 63 |
|
67 |
| - Note: Only the most basic .vue file layout is supported. The .vue file must have exactly one `<template>` section, one `<script>` section, and NO `<style>` section.\ |
68 |
| - The `<script>` section must start with `export default {`\ |
69 |
| - See [car.vue](sample-web-site/car.vue) as an example.\ |
70 |
| - For now, the .vue file `<script>` section will only be included in the rendered JavaScript when the control's |
71 |
| - `VueLight` attribute set to false (or is not present). |
72 |
| - |
73 |
| -- **ScriptTemplate** |
| 64 | +## Examples |
74 | 65 |
|
75 |
| - Used to render HTML in a `<script type="x-template">` tag. |
| 66 | +- [Using Component and App controls with Vue.js](sample-web-site/sample-vuejs.aspx) |
| 67 | +- [Using Component and App controls with Vue Light .NET Compiler](sample-web-site/sample-vuelight.aspx) |
| 68 | +- [Using Template control](sample-web-site/sample-template.aspx) |
| 69 | +- [Using .vue file](sample-web-site/sample-vue-file.aspx) |
76 | 70 |
|
77 |
| - The only purpose of this is to get HTML syntax highlighting and intellisense in the HTML editor in Visual Studio. This is not really specific to Vue.js in any way, but is convenient when authoring more complex Vue.js applications / components. |
78 | 71 |
|
79 |
| - Parameters: |
80 |
| - - `ID` - will be rendered as the ID for the script tag. |
| 72 | +## Note about .vue files |
81 | 73 |
|
82 |
| - [Example of use in a Web Forms page](sample-web-site/sample-scripttemplate.aspx) |
| 74 | +You can specify a .vue file in the `File` parameter of the **Component** and **App** controls |
83 | 75 |
|
| 76 | +Only the most basic .vue file layout is supported: |
| 77 | +- The .vue file must have exactly one `<template>` section, one `<script>` section, and NO `<style>` section. |
| 78 | +- The `<script>` section must start with `export default {` |
84 | 79 |
|
85 |
| -Common for the **Render**, **Component**, and **ScriptTemplate** controls above is that their content is used as the Vue.js template - for example: |
| 80 | +See [car.vue](sample-web-site/car.vue) as an example. |
86 | 81 |
|
87 |
| - <vl:Render runat="server"> |
88 |
| - <ul v-show="z"> |
89 |
| - <li v-for="x in y">{{x}}</li> |
90 |
| - </ul> |
91 |
| - </vl:Renter> |
| 82 | +For now, the .vue file `<script>` section will only be included in the rendered JavaScript when the control's |
| 83 | + `VueLight` attribute set to false (or is not present). |
92 | 84 |
|
93 |
| -The **FileComponent** control does not support any content (template is obtained from the .vue file instead). |
94 | 85 |
|
95 | 86 |
|
96 | 87 | ## License
|
|
0 commit comments