首先你必須掌握css、html、js,然后你得了解vue 該指南不做過多的技術(shù)層面介紹,只對一些項目中已經(jīng)封裝的方法/類進行介紹,以方便在需要時快速應(yīng)用,減少自己寫代碼的時間
-
?拼接每個單詞-box
?命名-item
?命名例如:
.main-box{
.main-item{
.main-right{
}
.main-right{
}
}
}
get``set
?的就用?get``set
?以下為常規(guī)目錄結(jié)構(gòu)
項目作者把js、css寫到單獨的目錄下,這樣看起來干凈,寫css和js更快,你也可以直接寫vue文件中
components的vue文件首字母大寫,用于區(qū)分它是組件
.
└── product
├── components
│ ├── js
│ │ ├── detail.js
│ ├── scss
│ │ ├── detail.scss
│ ├── Detail.vue
├── js
│ ├── list.js
├── scss
│ ├── list.scss
└── list.vue
<template>
<view>
<view>
時間為:{{time}}
</view>
</view>
</template>
<script>
export { parseTime } from '@/utils'
export default{
data() {
return {
time: null,
timestamp: '1581170184'
}
},
onLoad() {
this.time = parseTime(this.timestamp, 'yyyy-mm-dd');
}
}
</script>
specification
?控制生成的圖片尺寸<template>
<view>
<view>
<img :src="img | smallImage(150)">
</view>
</view>
</template>
<script>
export default{
data() {
return {
img: '1581170184.jpg'
}
},
onLoad() {
this.img = smallImage(this.img, 150);
}
}
</script>
element
?組件,以下只對如何使用說明,不進行組件基礎(chǔ)說明el-table-column
?添加?sortable="custom" prop="id"
?<el-table-column label="編號" sortable="custom" prop="id">
<template slot-scope="scope">
<span>{{ scope.row.id }}</span>
</template>
</el-table-column>
// 重新獲取API數(shù)據(jù)
handleFilter() {
this.listQuery.page = 1
this.getList()
},
// 排序
sortChange(data) {
const { prop, order } = data
if (order === 'ascending') {
this.listQuery.sort = '+' + prop
} else {
this.listQuery.sort = '-' + prop
}
this.handleFilter()
},
參數(shù) | 類型 | 是否必填 | 說明 |
---|---|---|---|
type | int | 是 | 1圖片 |
size | int | 是 | 上傳大小限制 |
specification | array | 是 | 生成的圖片尺寸 |
imgMasterData: {
type: 1,
size: 1024 * 1024 * 2,
specification: [80, 150, 200, 250, 300, 350]
},
admin\src\views\Dashboard\index.vue
?created() {
if (!this.roles.includes('admin')) {
this.currentRole = 'editorDashboard'
}
}
<script>
export default{
onLoad() {
this.loginCheck()
},
methods:{
...mapMutations(['loginCheck']),
}
}
</script>
<script>
export default{
onLoad() {
if (this.hasLogin){
}
},
computed:{
...mapState(['hasLogin'])
},
}
</script>
<script>
import { urlToObj } from 'utils'
export default{
onLoad(options) {
const q = decodeURIComponent(options.q)
const url = urlToObj(q)
}
}
</script>
<template>
<view>
<view>
時間為:{{time}}
</view>
</view>
</template>
<style lang='scss'>
.avatar-uploader .el-upload{
width: 250px;
height: 250px;
}
</style>
<script>
export { parseTime } from '@/utils'
export default{
data() {
return {
time: null,
timestamp: '1581170184'
}
},
onLoad() {
this.time = parseTime(this.timestamp, 'yyyy-mm-dd');
}
}
</script>
參數(shù) | 類型 | 是否必填 | 默認(rèn)值 | 說明 |
imgData | Object | 否 | { type: 1, size: 1024 * 1024 * 2, specification: [80, 150] } | 上文中的后臺上傳參數(shù)-上傳參數(shù)說明 |
format | Array | 否 | [ 'image/jpeg', 'image/gif', 'image/png', 'image/bmp' ] | 允許上傳的格式,此處為前端驗證格式,非后臺驗證格式 |
limit | Number | 否 | 5 | 允許上傳文件的數(shù)量 |
fileList | Array | 否 | [] | 已上傳的圖片 |
示例:
<template>
<insert-image :fileList="fileList" @getFile="getFile"/>
</template>
<script>
import InsertImage from '@/components/Upload/InsertImage'
export default {
components: {
InsertImage
},
data() {
return {
fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],
}
},
methods: {
getFile(res){
console.log('res', res)
}
}
}
</script>
參數(shù) | 類型 | 是否必填 | 默認(rèn)值 | 說明 |
---|---|---|---|---|
imgData | Object | 否 | { type: 1, size: 1024 * 1024 * 2, specification: [80, 150] } | 上文中的后臺上傳參數(shù)-上傳參數(shù)說明 |
format | Array | 否 | [ 'image/jpeg', 'image/gif', 'image/png', 'image/bmp' ] | 允許上傳的格式,此處為前端驗證格式,非后臺驗證格式 |
file | String | 是 | '' | 已上傳的圖片,沒有傳空,不然上傳的圖片將無法展示 |
示例:
<template>
<avatar-image :file="file" @getFile="getFile"/>
</template>
<script>
import AvatarImage from '@/components/Upload/AvatarImage'
export default {
components: {
AvatarImage
},
data() {
return {
file: '',
}
},
methods: {
getFile(res){
this.file = res.response
console.log('res', res)
}
}
}
</script>
NODE_ENV=prod //當(dāng)前環(huán)境
APP_DEBUG=true //調(diào)試模式
APP_NAME=DSSHOP商城-跨終端商城解決方案 //項目名稱
APP_SHORT_NAME= DSSHOP //項目簡稱
APP_DESCRIPTION=免費開源可商用,快速搭建屬于自己的獨立商城網(wǎng)店系統(tǒng),一次搭建適配多終端 //項目全局描述
APP_KEYWORD=商城網(wǎng)店系統(tǒng)|商城|網(wǎng)店|免費商城|免費網(wǎng)店 // 項目全局關(guān)鍵字
APP_ICP=浙ICP備110120119 // 項目備案號
API_URL_BROWSER=http://dsshop.test/api/v1/app/ //項目訪問地址,暫時沒有使用
API_URL=http://dsshop.test/api/v1/app/ //項目api地址
PROJECT_KEY=base64:szoJ3mSx/5U7zOsJfU7s4pSahiwdh01x6badmz5FtCM= //前端密鑰
CACHE_PR=DSSHOP-PC- //項目緩存前綴
IBS_KEY= //騰訊地圖地圖密鑰,可通過https://lbs.qq.com注冊創(chuàng)建應(yīng)用
nuxt使用?store
?或?route
?推薦使用$nuxt
#vue中使用:
this.$store.state.hasLogin
#nuxt中使用:
$nuxt.$store.state.hasLogin
if(!$nuxt.$store.state.hasLogin){
$nuxt.$store.commit('loginCheck')
return false
}
在?uesr
?目錄下新建一個?_id.vue
?文件,然后在?_id.vue
?中用?params
?接收參數(shù)
web\assets\css\main.scss
?的?$font-color-main
?web\nuxt.config.js
?的?loading
?的?color
?export default {
loading: {
color: '#fa524c',
height: '2px'
},
....
}
根據(jù)element-ui設(shè)置主題,然后替換掉?web\assets\theme
?目錄下的所有文件
使用了store.js
// 設(shè)置緩存
this.store.set('user', { name:'Marcus' })
// 讀取緩存
this.store.get('user')
// 刪除緩存
this.store.remove('user')
// 清空緩存
this.store.clearAll()
// 循環(huán)遍歷所有存儲的值
this.store.each(function(value, key) {
console.log(key, '==', value)
})
更多建議: