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