Skip to content

Commit 210d599

Browse files
author
Ferry To
authored
Merge pull request #1 from ferrywlto/VueBootstrap
code fix and Bootstrap
2 parents fc89b2f + 12f497e commit 210d599

File tree

7 files changed

+31
-5
lines changed

7 files changed

+31
-5
lines changed

ClientApp/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import Vue from 'vue'
22
import App from './components/App.vue'
33
import store from './vuex/store.js'
44
import router from './router'
5+
import BootstrapVue from 'bootstrap-vue'
6+
7+
Vue.use(BootstrapVue)
58

69
const app = new Vue({
710
router,

ClientApp/client.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import NProgress from 'nprogress'
22
import 'nprogress/nprogress.css'
3+
4+
import 'bootstrap/dist/css/bootstrap.css'
5+
import 'bootstrap-vue/dist/bootstrap-vue.css'
6+
37
import {
48
app,
59
router,

ClientApp/components/Dashboard.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<template>
2+
<div>
23
<h1>Dashboard</h1>
4+
<b-badge variant="primary">Hello Bootstrap</b-badge>
5+
</div>
36
</template>

ClientApp/vuex/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const fetchInitialMessages = ({commit}) => {
1010
}
1111

1212
export const fetchMessages = ({commit}, lastFetchedMessageDate) => {
13-
axios.get('/fetchMessages?lastFetchedMessageDate=' + lastFetchedMessageDate)
13+
axios.get('http://localhost:5000/fetchMessages?lastFetchedMessageDate=' + lastFetchedMessageDate)
1414
.then(response => {
1515
commit('FETCH_MESSAGES', response.data)
1616
}).catch(err => {

Controllers/HomeController.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ public JsonResult initialMessages(){
3434

3535
[Route("fetchMessages")]
3636
public JsonResult FetchMessages(DateTime lastFetchedMessageDate){
37-
return Json(FakeMessageStore.FakeMessages.OrderByDescending(m => m.Date)
38-
.SkipWhile(m => m.Date >= lastFetchedMessageDate).Take(1));
37+
return Json(Message.CreateMessage(
38+
"New Message",
39+
DateTime.Now.Millisecond.ToString(),
40+
DateTime.Now
41+
));
3942
}
4043
}
4144
}

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# README
22

3-
This repository was built from scratch following the steps described in the original blog post *[Server rendering Vue.js applications with ASP.NET Core](https://stu.ratcliffe.io/2017/07/20/vuejs-serverside-rendering-with-aspnet-core)* from Stu Ratcliffe. The aim of this repository is to adding more steps and comments from my experience following the steps that make it works as a supplement of the original blog post. Hope this helps if you also read the same blog post and got stuck some way. :)
3+
This repository was built from scratch following the steps described in the original blog post *[Server rendering Vue.js applications with ASP.NET Core](https://stu.ratcliffe.io/2017/07/20/vuejs-serverside-rendering-with-aspnet-core)* from Stu Ratcliffe. The aim of this repository is to adding more steps and comments from my experience following the steps that make it works as a supplement of the original blog post. I personally did not have any prior knowledge in VueJS nor modern web development frameworks. I were a C# developer and learn VueJS by my own from VueJS documentation and Stu Ratcliffe blog post. Hope this helps if you also read the same blog post and got stuck some way. :pray: :grinning:
44

55
You can get the complete code repo made by Stu Ratcliffe from [[Here]](https://github.com/sturatcliffe/VueDotnetSSR)
66

@@ -119,4 +119,15 @@ To simulate timely API call form remote server, we add the following line in Hom
119119
- Edit `webpack.config.js`, make use of `webpack-merge` to split the original configuration into two sets.
120120

121121
### Thoughts:
122-
SSR was by far the most difficult part of my VueJS journey, it takes more than half of the time of my VueJS learning. Whether to use Server Side Rendering or not is highly optional, you don't need it to write a cool SPA. The performance and user experience gain is arguablely worth the complexity and develop time involved.
122+
SSR was by far the most difficult part of my VueJS journey, it takes more than half of the time of my VueJS learning. Whether to use Server Side Rendering or not is highly optional, you don't need it to write a cool SPA. The performance and user experience gain is arguablely worth the complexity and develop time involved.
123+
124+
### BootstrapVue:
125+
Bootstrap is a very popular library for beautiful and simple UI components and styles.
126+
Using Bootstrap in VueJS application is easy with BootstrapVue:
127+
128+
- Install: `npm i bootstrap-vue bootstrap@4.0.0-beta.2`
129+
- Import into app.js: `import BootstrapVue from 'bootstrap-vue'
130+
- Import the css files: (tricky here, for this repo I need to add the imports at client.js instead of app.js)
131+
import 'bootstrap/dist/css/bootstrap.css'
132+
import 'boostrap-vue/dist/bootstrap-vue.css'
133+
- Add the Bootstrap components (e.g. I added a badge at Dashboard.vue template.)

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"dependencies": {
1313
"aspnet-prerendering": "^1.0.1",
1414
"axios": "^0.17.1",
15+
"bootstrap": "^4.0.0-beta.2",
16+
"bootstrap-vue": "^1.3.0",
1517
"lodash": "^4.17.4",
1618
"nprogress": "^0.2.0",
1719
"vue": "^2.5.9",

0 commit comments

Comments
 (0)