Modal
[[官方文档-modal]](https://bootstrap-vue.js.org/docs/components/modal/#comp-ref-b-modal)
----
[TOC]
----
## Confirm message box
~~~javascript
//.vue中
//异步处理文件上传
export default {
methods:{
uploadFile:async function(obj,event){
//event.preventDefault
//console.log(event.target)
//var inputFile=null
let self=this
let url=[self.host,self.actItem.sysEnt,'uploadFile',obj.id].join('/')
let req=Object.assign({},self.request)
let file=req.load
//异步引入TheFormFile组件
const {default:formFileCom}=await Promise.resolve(import('@/components/TheFormFile'))
//引入定义好的渲染函数
const h = self.renderFunc()
/*const bodyVNode = h('p', { class: ['text-center'] }, [
h('strong', {}, obj.id)
])*/
/*
const bodyVNode=h('b-form-file', { class: ['text-center'] }, [
h('strong', {}, obj.id)
])
*/
//TODO: h(formFileCom) ?
//使用渲染函数进行BSV的msgBoxConfirm组件关键部分的渲染
/*
const bodyVNode = h(formFileCom,{
props: {
file: null
},
on:{
input-file:function(){
return this.file
}
},
})
*/
const bodyVNode = h(formFileCom)
const titleVNode = h('div', { domProps: { innerHTML: '上传<strong> '+obj.name+' </strong>照片?' } })
//得到BSV的msgBoxConfirm组件的按钮值
let modalVal=await self.$bvModal.msgBoxConfirm([bodyVNode], {
title:[titleVNode],
size: 'sm',
buttonSize: 'sm',
okVariant: 'primary',
okTitle: '是',
cancelTitle: '否',
footerClass: 'p-2',
hideHeaderClose: false,
centered: true
})
let res={'status':0}
let data={success:false}
//console.log(event.target.id)
if(modalVal){
const formData = new FormData()
console.log(file)
//定义后端提取文件的名称:fileObj
formData.append('fileObj', file)
//向后端上传文件
//使用formData上传文件,method必须为‘PSOT’
res=await fetch(url,{
method:'POST',
body:formData
})
}
//后端成功处理
if(res.status=='200'){
//得到后端发回的数据
data=await res.json()
}
console.log(data)
console.log(event)
//TODO: change b-img src prop sync?
//更新event.target.src
if(data.success){
//event.target.src=data.dir+data.name
event.target.src=self.setImgSrc(data)
}
await self.$nextTick()
console.log(event.target.src)
console.log(event.target.currentSrc)
/*
self.$bvModal.msgBoxConfirm([bodyVNode], {
title:[titleVNode],
size: 'sm',
buttonSize: 'sm',
okVariant: 'primary',
okTitle: '是',
cancelTitle: '否',
footerClass: 'p-2',
hideHeaderClose: false,
centered: true
})
.then(value => {
let url=[self.host,self.actItem.sysEnt,'uploadPic',obj.id].join('/')
let req=Object.assign({},self.request)
let file=req.load
//let file1=new File()
console.log(value)
console.log(file)
//console.log(file1)
//按下的是‘ok’
//if(value && file.name){
if(value){
const formData = new FormData()
formData.append('image', file)
console.log(url)
console.table(file)
console.log(formData)
//使用formData上传文件,method必须为‘PSOT’
return fetch(url,{
method:'POST',
body:formData
})
}
if(!value){
req.load={}
console.log(file)
return self.updateFetchCont({request:req})
}
})
.then(res=>{
if(res.status=='200'){
return res.json()
}
})
.then(obj=>{
console.log(obj)
})
.catch(err => {
// An error occurred
return err
})
*/
},
},
}
~~~
- WebAPP
- Linux Command
- 入门
- 处理文件
- 查找文件单词
- 环境
- 联网
- Linux
- Linux目录配置标准:FHS
- Linux文件与目录管理
- Linux账号管理与ACL权限设置
- Linux系统资源查看
- 软件包管理
- Bash
- Daemon/Systemd
- ftp
- Apache
- MySQL
- Command
- Replication
- mysqld
- remote access
- remark
- 限制
- PHP
- String
- Array
- Function
- Class
- File
- JAVA
- Protocals
- http
- mqtt
- IDE
- phpDesigner
- eclipse
- vscode
- Notepad++
- WebAPI
- Javasript
- DOM
- BOM
- Event
- Class
- Module
- Ajax
- Fetch
- Promise
- async/await
- Statements and declarations
- Function
- Framwork
- jQurey
- Types
- Promise
- BootStrap
- v4
- ThinkPHP5
- install
- 定时任务
- CodeIgniter
- React.js
- node.js
- npm
- npm-commands
- npm-folder
- package.json
- Docker and private modules
- module
- webpack.js
- install
- configuration
- package.json
- entry
- modules
- plugins
- Code Splitting
- loaders
- libs
- API
- webpack-cli
- Vue.js
- install
- Compile
- VueAPI
- vuex
- vue-router
- vue-devtools
- vue-cli
- vue-loader
- VDOM
- vue-instance
- components
- template
- Single-File Components
- props
- data
- methods
- computed
- watch
- Event-handling
- Render Func
- remark
- 案例学习
- bootstrap-vue
- modal
- fontAwesome
- Hosting Font Awesome Yourself
- using with jquery
- using with Vue.js
- HTML
- CSS
- plugins
- Chart.js
- D3.js
- phpSpreadSheet
- Guzzle
- Cmder
- Git
- git命令
- git流程
- Postman
- Markdown
- Regular Expressions
- PowerDesigner
- 附录1-学习资源