1.0.2 • Published 1 year ago
open-nvue v1.0.2
Quickly open the uniapp nvue subwindow utility function
Installtion
npm i open-nvue
example
import openNvue from "open-nvue";
export default {
methods: {
openDemo() {
const demo = openNvue("demo");
// When the demo.nvue fires the submit event
// Event name needs to be concatenated with an id, `uni.$emit('demo-submit')`
// Because multiple Windows may trigger the same event repeatedly
const offSubmit = demo.on("submit", (value) => {
console.log(value); // log data
demo.close(); // close the nvue window
offSubmit(); // Turn off event listening
});
},
},
};
Options
// Type
openNvue(ID: string, Options?: OpenNvueOptions): OpenNvueReturnValue
interface OpenNvueOptions {
// Use `uni.$on(`demo-load`, (data) => {})` to receive initialization data in the no default subwindow
data?: any
// the default value is `slide-in-bottom`
transition?: string
// the default value is `slide-out-bottom`
outTransition?: string
// the default value is `300`
duration?: number
}
type OffFn = () => void
interface OpenNvueReturnValue {
// Listen for subwindow events
on: (name: string, callback: (data?: any) => OffFn)
// close the subwindow
close: () => void
}