我在mozilla插件中有一个首选项,其类型为bool,但是当用户更改首选项时,从javascipt中访问该首选项时不会改变。

package.json:

{
    "name": "myaddon",
     ..
     "preferences": [
      {
          "name": "extensions.myaddon.datestamp",
          "title": "Date stamp?",
          "description": "Add date to saved file name",
          "type": "bool",
          "value": "true"
      }]
}

main.js:
'use strict';
const prefs = require("simple-prefs");

var datestamp = prefs.prefs['extensions.myaddon.datestamp'];
console.log(datestamp);

始终输出info: myaddon: true,即使未选中首选项?

最佳答案

尝试使用不带双引号的"value" :true,

09-25 19:14