我希望能够在 Astro 中拥有一个动态页面来呈现 Astro 组件。我深入研究了文档和代码,但找不到像下面这样的函数(Astro.render)。理想情况下,我可以将属性传递给它。我正在寻找类似的东西react.renderToString。
import Example from './components/Example.astro'
export async function get() {
return {
body: Astro.render(Example)
};
}
Run Code Online (Sandbox Code Playgroud)
更新:我认为这里的每个答案都是错误的。给定一个 astro 文件,我想要一个node独立于运行时 astro 框架的函数,它可以接受 astro 文件并简单地返回一个Response(因为我知道 astro 文件可以返回来自 front-matter 的响应)和/或HTML字符串?我认为它可以是像这样的元组[res, htmlString]。就像可以转换 Markdown 文件一样,astro 文件也应该能够被处理。
当我运行我的 expo / jest 项目时,我收到这些警告,我不知道为什么,在谷歌搜索时似乎没有出现。
console.warn
The "EXNativeModulesProxy" native module is not exported through NativeModules; verify that expo-modules-core's native code is linked properly
at Object.<anonymous> (node_modules/expo-modules-core/src/NativeModulesProxy.native.ts:54:11)
at Object.<anonymous> (node_modules/expo-modules-core/src/index.ts:4:1)
console.warn
No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?
at Object.<anonymous> (node_modules/expo-constants/src/Constants.ts:32:11)
at Object.<anonymous> (node_modules/expo-asset/src/PlatformUtils.ts:2:1)
Run Code Online (Sandbox Code Playgroud) 我有一个带有几种方法的控制器,它们都有相同的变量.我正在寻找一种方法让他们共享相同的变量.做这个的最好方式是什么?
我现在拥有的:
class Example extends CI_Controller{
public function test{
$variable = "awesome";
}
public function demo{
$variable = "awesome";
}
}
Run Code Online (Sandbox Code Playgroud) 我有一点正则表达式的麻烦.
我想在这个网址中找到路径videoplay.
http://video.google.co.uk:80/videoplay?docid=-7246927612831078230&hl=en#hello
Run Code Online (Sandbox Code Playgroud)
如果我使用这个正则表达式/.+也匹配/video.
我需要某种反/负匹配不包括在内 //
我可以使用以下内容制作HMAC:
var encrypt = crypto.createHmac("SHA256", secret).update(string).digest('base64');
Run Code Online (Sandbox Code Playgroud)
我试图用秘密解密编码的HMAC:
var decrypt = crypto.createDecipher("SHA256", secret).update(string).final("ascii");
Run Code Online (Sandbox Code Playgroud)
以下是不成功的.如何用密钥解密HMAC?
我收到以下错误:
node-crypto : Unknown cipher SHA256
crypto.js:155
return (new Decipher).init(cipher, password);
^
Error: DecipherInit error
Run Code Online (Sandbox Code Playgroud) 我正在使用griddle一个react组件来创建一个表.
Griddle支持额外的属性来显示过滤器输入元素,该元素操纵表格.
有没有办法使用自己独立的表格/输入与平板炉.那么当提交第三方输入时,我可以在griddle中触发一些函数来更新表吗?
有没有什么方法可以让我把一个类称为函数.我正在寻找下面的功能,其中有一个main类中的方法,这是我想让方法执行的方法.
class test {
constructor () {
return this.main
}
main () {
return Promise.resolve('thomas')
}
}
test().then(name => {
console.log(name)
})
Run Code Online (Sandbox Code Playgroud)
看来我唯一的另一个选择是拥有这样的包装函数.
class Test {
constructor (name) {
this.name = name
}
main () {
return Promise.resolve(this.name)
}
}
let test = (name) => {
return new Test(name).main()
}
test('thomas').then(name => {
console.log(name)
})
Run Code Online (Sandbox Code Playgroud) 我想知道GraphiQL中是否有一种方法可以让我将一个查询/突变的结果传递给另一个查询/突变.下面是其中的一个例子login突变来获得viewer与viewer将用于查询addresses该用户.这可能是GraphQL/GraphiQL.
mutation {
login(credentials: {
email: "me@me.com",
password: "password123",
passwordConfirmation: "password123"
}) {
viewer
}
}
query {
addresses(viewer:viewer) {
city
}
}
Run Code Online (Sandbox Code Playgroud) 出于某种原因,我很难从中获取原始的身体event.它将内容类型记录$input.body为json application/json.文档说应该包含原始有效负载.
这是我的集成请求主体映射模板:
{
"body" : $input.json('$'),
"rawBody": $input.body,
"headers": {
#foreach($header in $input.params().header.keySet())
"$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end
#end
},
"method": "$context.httpMethod",
"params": {
#foreach($param in $input.params().path.keySet())
"$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end
#end
},
"query": {
#foreach($queryParam in $input.params().querystring.keySet())
"$queryParam": "$util.escapeJavaScript($input.params().querystring.get($queryParam))" #if($foreach.hasNext),#end
#end
}
}
Run Code Online (Sandbox Code Playgroud)
这是有效载荷示例:
{
"event": {
"body": {
"hello": "meow"
},
"rawBody": {
"hello": "meow"
},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-US",
"Cache-Control": "no-cache",
"CloudFront-Forwarded-Proto": "https",
"CloudFront-Is-Desktop-Viewer": "true",
"CloudFront-Is-Mobile-Viewer": "false",
"CloudFront-Is-SmartTV-Viewer": …Run Code Online (Sandbox Code Playgroud) 下面我有一个我期望的方法来创建一个GeoJSON MultiPolygon对象,其中有一个多边形,有两个"洞".
当我使用服务http://geojson.io/来验证这个对象时,它会返回一个错误each element in a position must be a number并且它不会渲染,但是如果我删除了"holes"嵌套,删除其中一个然后它就可以了.
我正在寻找一种方法来描述MultiPolygon多边形可以有多个孔的位置.
我不是在代码中寻找一种创建带孔的多边形的方法.
我正在寻找一种方法来使用GeoJSON规范来表示具有多个孔的MultiPolygons.
{
"type": "MultiPolygon",
"coordinates": [
[
[
[
-73.98114904754641,
40.7470284264813
],
[
-73.98314135177611,
40.73416844413217
],
[
-74.00538969848634,
40.734314779027144
],
[
-74.00479214294432,
40.75027851544338
],
[
-73.98114904754641,
40.7470284264813
]
],
[
[
[
-73.99818643920906,
40.74550031602355
],
[
-74.00298643920905,
40.74550031602355
],
[
-74.00058643920897,
40.74810024102966
],
[
-73.99818643920906,
40.74550031602355
]
],
[
[
-73.98917421691903,
40.73646098717515
],
[
-73.99397421691901,
40.73646098717515
],
[ …Run Code Online (Sandbox Code Playgroud) javascript ×4
node.js ×2
astrojs ×1
aws-lambda ×1
class ×1
cryptography ×1
ecmascript-6 ×1
expo ×1
forms ×1
geojson ×1
graphql ×1
griddle ×1
hmac ×1
html-table ×1
jestjs ×1
json ×1
php ×1
polygon ×1
reactjs ×1
regex ×1
sha256 ×1
url ×1