优化奶茶首页provide/inject的代码
This commit is contained in:
parent
0300d56ec5
commit
6f2b32391f
|
@ -15,7 +15,7 @@ function vitePluginRemoveDir(options = {}) {
|
|||
const distDir = path.resolve(process.cwd(), 'dist');
|
||||
// 构建结束后执行的逻辑
|
||||
for(const item of dirName){
|
||||
const fullPath = path.join(distDir, ['production','test'].includes(process.env.NODE_ENV) ? 'build' : 'dev',process.env.UNI_PLATFORM,`static/${item}`); // 构造要删除的目录的完整路径
|
||||
const fullPath = path.join(distDir, ['production'].includes(process.env.NODE_ENV) ? 'build' : 'dev',process.env.UNI_PLATFORM,`static/${item}`); // 构造要删除的目录的完整路径
|
||||
console.log('fullPath',fullPath);
|
||||
// 尝试删除目录
|
||||
try {
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
import config from '../config'
|
||||
const clickBuy = inject('handleBuy');
|
||||
const goDetail = inject('goDetail');
|
||||
const { handleBuy, goDetail } = inject('custom-events')
|
||||
const props = defineProps({
|
||||
detail:{
|
||||
type:Object,
|
||||
|
@ -43,7 +42,7 @@
|
|||
if(e.stopPropagation) { //W3C阻止冒泡方法
|
||||
e.stopPropagation();
|
||||
}
|
||||
clickBuy(props.detail)
|
||||
handleBuy(props.detail)
|
||||
}
|
||||
const toDetail = () => {
|
||||
goDetail(props.detail)
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
const productList = ref([]);
|
||||
const authCode = ref('');
|
||||
|
||||
|
||||
const handleBuy = (productData) => {
|
||||
pay(productData)
|
||||
}
|
||||
|
@ -57,8 +56,10 @@
|
|||
})
|
||||
}
|
||||
|
||||
provide('handleBuy', handleBuy);
|
||||
provide('goDetail', goDetail);
|
||||
provide('custom-events',{
|
||||
handleBuy,
|
||||
goDetail
|
||||
})
|
||||
|
||||
const toOrder = () => {
|
||||
uni.navigateTo({
|
||||
|
|
|
@ -16,8 +16,6 @@ const timeStringNow = dayjs().format("MM-DD HH-mm-ss")
|
|||
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const { UNI_PLATFORM } = process.env // 得到 mp-weixin, h5, app 等
|
||||
console.log(process.env.NODE_ENV);
|
||||
console.log({command,mode});
|
||||
return {
|
||||
plugins: [
|
||||
UniPages({
|
||||
|
|
Loading…
Reference in New Issue