Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用离子电容器和框架设置本地通知7_Javascript_Html Framework 7_Capacitor - Fatal编程技术网

Javascript 使用离子电容器和框架设置本地通知7

Javascript 使用离子电容器和框架设置本地通知7,javascript,html-framework-7,capacitor,Javascript,Html Framework 7,Capacitor,我使用离子电容器和框架7进行应用。我想使用电容器本地通知插件实现本地通知。但是,它给了我未捕获的引用错误:未定义LocalNotifications //Importing plugin import {Plugins} from '../node_modules/@capacitor/core'; const {LocalNotifications} = Plugins; //Schedule Local Notifcations LocalNotifications.schedul

我使用离子电容器和框架7进行应用。我想使用电容器本地通知插件实现本地通知。但是,它给了我未捕获的引用错误:未定义LocalNotifications

//Importing plugin
import  {Plugins}  from '../node_modules/@capacitor/core';
const  {LocalNotifications}  = Plugins;

//Schedule Local Notifcations
LocalNotifications.schedule({
        notifications: [{
            title: "Title",
            body: "Body",
            id: 1,
            schedule: {
                at: new Date(Date.now() + 1000 * 5)
            },
            sound: 'res://audio/android/iphone_6.mp3',
            attachments: null,
            actionTypeId: "",
            extra: null
        }]
    });

未捕获引用错误:未定义LocalNotifications

尝试从“@capactor/core”导入
插件
导入{Plugins}

只是在@igor\u c提到的插件导入方式的基础上进行构建。您需要像上面建议的那样导入插件,然后从
const{LocalNotifications}=Plugins这样的插件中提取LocalNotifications实例
我在Android上也遇到了同样的问题,这个解决方案解决了这个问题,我认为这与vscode导入libs的方式有关。。。
//Importing plugin
import  {Plugins}  from '../node_modules/@capacitor/core';
const  {LocalNotifications}  = Plugins;

//Schedule Local Notifcations
LocalNotifications.schedule({
        notifications: [{
            title: "Title",
            body: "Body",
            id: 1,
            schedule: {
                at: new Date(Date.now() + 1000 * 5)
            },
            sound: 'res://audio/android/iphone_6.mp3',
            attachments: null,
            actionTypeId: "",
            extra: null
        }]
    });