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