Last week, I created a news applicaiton by using Vue.js and ElementUI
Install Vue
Install Vue.js by using the cli.
See the document here
Install ElementUI
Install ElementUI. See the document here
Apply an API key from News API
Apply from here
Install Vue-axios
Vue-axios is a tool for sending get request in our application.
Follow the document here
Install vue-lazyload
A Vue.js plugin for lazyload your Image or Component in the application.
Install from here
Install Vuex
Vuex is a state management pattern + library for Vue.js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion. It also integrates with Vue’s official devtools extension to provide advanced features such as zero-config time-travel debugging and state snapshot export / import.
1 | npm install vuex --save |
Explicitly install Vuex via Vue.use()
:
1 | import Vue from 'vue' |
Then in the src/main.js
file. Create a store variable
1 | /* eslint-disable no-new */ |
SourceList components
Create a file named ‘SourceList.vue’ under the /src/components
folder.
1 | <template> |
NewsList component
Create a file named ‘NewsList.vue’ under the /src/components
folder.
1 | <template> |
Using two components
In src/App.vue
. Change the file to this:
1 | <template> |