适用于该包的导入是:
import Fiona from 'https://deno.land/x/fiona/deno/index.js'
const seeded = Fiona(2983938);
const data = seeded.object({
name: Fiona.Fullname,
age: Fiona.Number({ max: 100 }),
});
console.log(data); // { name: "Miss Fiona Moon", age: 1 }
或者
import bootstrap from 'https://deno.land/x/fiona/bootstrap.js'
const Fiona = bootstrap();
const seeded = Fiona(2983938);
const data = seeded.object({
name: Fiona.Fullname,
age: Fiona.Number({ max: 100 }),
});
console.log(data); // { name: "Miss Fiona Moon", age: 1 }
import Fiona from 'https://deno.land/x/fiona/index.js';
上述导入失败:
error: relative import path "randexp" not prefixed with / or ./ or ../ Imported from "https://deno.land/x/fiona/index.js"
index.js
因为由于包在做,所以有一个错误:
import RandExp from 'randexp'
这对 Deno 无效。这就是index.js
Node.js
import Fiona from 'https://deno.land/x/fiona';
这个失败是因为与 Node.js 不同,默认情况下,当您导入文件夹时,Deno 不会加载index.js
。