Addons
Addon features for Vue projects build by Diamond.
Last updated
Addon features for Vue projects build by Diamond.
Last updated
These addons are integrated into the Diamond scaffolding generator. You can choose which addons to install during the scaffolding process.
SVG addon is based on the svg-sprite-loader. This addon is a Webpack loader for creating SVG sprites.
Diamond generator not only added the loader, also provide a SVG component for SVG usage. By adding this addon, we can simply start using the component right away without having to write any code.
First, the generator will create a src/icons/
folder, this is specially created for storing the .svg
files. The folder has the following files:
Second, the generator will create the SVG Compoment at src/components/SvgIcon/
folder. With the following structure.
Use of this component is simple.
This component has being register globally. Therefor we cang put use this component anywhere in side our page.
The name
attribute is the name of your SVG file that you put in src/icons/
folder.
API addon is built base on Axios, a promise based HTTP client for the browser and node.js.
This addon is pre-configured by Diamond Generator, used for requesting APIs.
First a request helper has been pre-built at src/utils/request.js
. This is made speically for Vue
with Axios
, pre-configured out of the box.
Secondly there is a src/api/
folder, this is for store all our API files.
Using the API addon is simple, first create a API file in src/api/
folder like this:
Then, import API file to your vue page or component where you need to request an API.
Since the Axios is promise based HTTP client, therefore can use .then
and .catch
promise chain.
Working in Progress