受不了ts了
This commit is contained in:
@@ -1,14 +1,21 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { myfuncs } from './myfunc'
|
import { myfuncs } from './myfunc'
|
||||||
|
|
||||||
|
interface re_data {
|
||||||
|
statusCode: number
|
||||||
|
cookie?: string
|
||||||
|
error?: string
|
||||||
|
data?: JSON
|
||||||
|
}
|
||||||
|
|
||||||
export const my_network_func = {
|
export const my_network_func = {
|
||||||
post_json(path: string) {
|
post_json(path: string, json: JSON, callback: (i: re_data) => void) {
|
||||||
const head_path = '/api/v1'
|
const head_path = '/api/v1'
|
||||||
const url = head_path + path
|
const url = head_path + path
|
||||||
const cookie = myfuncs.load('cookie') || ''
|
const cookie = myfuncs.load('cookie') || ''
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
data: json,
|
||||||
cookie: cookie,
|
cookie: cookie,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +26,12 @@ export const my_network_func = {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(response)
|
const re: re_data = {
|
||||||
|
statusCode: response.status,
|
||||||
|
data: response.data,
|
||||||
|
}
|
||||||
|
callback(re)
|
||||||
|
//console.log(response)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('There was an error!', error)
|
console.error('There was an error!', error)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MyOffcanvas from '@/components/MyOffcanvas.vue'
|
import MyOffcanvas from '@/components/MyOffcanvas.vue'
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { my_network_func } from '@/my_network_func'
|
//import { my_network_func } from '@/my_network_func'
|
||||||
const mos = ref<InstanceType<typeof MyOffcanvas> | null>(null)
|
const mos = ref<InstanceType<typeof MyOffcanvas> | null>(null)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -14,25 +14,23 @@ function c() {
|
|||||||
mos.value?.showAlert('success', '111', 1000)
|
mos.value?.showAlert('success', '111', 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface User {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function d() {
|
function d() {
|
||||||
const jsonData = ref<User[]>([])
|
interface User {
|
||||||
jsonData.value = [
|
id: number
|
||||||
{ id: 1, name: 'Alice'}
|
name: string
|
||||||
]
|
}
|
||||||
|
|
||||||
const Users: User= { id: 0, name: '' }
|
const Users: Partial<User> = {}
|
||||||
Users.id = 2
|
Users.id = 2
|
||||||
Users.name = 'Bob'
|
Users.name = 'Bob'
|
||||||
|
|
||||||
|
const jsonData = ref<User[]>([])
|
||||||
|
jsonData.value = [{ id: 1, name: 'Alice' }]
|
||||||
|
|
||||||
|
|
||||||
console.log('Users:', Users)
|
console.log('Users:', Users)
|
||||||
|
|
||||||
my_network_func.post_json('/1')
|
//my_network_func.post_json('/1',jsonData.value[0],()=>{})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user