如何使用模板助手编辑传递给使用pathForiron-router方法创建的路由的参数值?
我有这个模板助手:
Template.registerHelper('slugify', function(obj){
return _.slugify(obj);
});
Run Code Online (Sandbox Code Playgroud)
在我的.html文件中我有这个:
{{#each menuItemsFromDB}}
{{#each arrayOfMenuItems}}
<a class="item category" href="">
{{this}}
</a>
{{/each}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)
在{{this}}上面的代码返回一个字符串,该类别的名称.因为我已经注册了模板助手,所以我可以通过以下方式来解决这个类别:
{{slugify this}}
Run Code Online (Sandbox Code Playgroud)
然后我有这条路线:
this.route('List',{
path: '/list/:category_slug',
template: 'list',
controller: 'ListController'
});
Run Code Online (Sandbox Code Playgroud)
我可以链接到此路由并通过以下方式将参数传递给此路由:
{{pathFor 'List' category_slug='the-value-i-passed'}}
Run Code Online (Sandbox Code Playgroud)
但那将是难以编码的,它无法达到我想要的预期效果.
我希望它是动态的,使用'slugify'模板助手和铁路由器的pathFor方法,并使用值{{this}}.
我想要实现的是这样的,虽然下面的代码不起作用:
{{pathFor 'List' category_slug={{slugify this}} }}
Run Code Online (Sandbox Code Playgroud)
通过以上线路实现我正在努力实现的目标是什么?
我希望我可以这样做:
{{pathFor 'List' category_slug=slugify(this) }}
Run Code Online (Sandbox Code Playgroud)
要么
{{pathFor 'List' category_slug='{{slugify this}}' }}
Run Code Online (Sandbox Code Playgroud) 我正在使用 NativeBase.io 编写 React Native 应用程序
在我使用 NativeBase 的应用程序中,我收到以下错误......如何解决此问题?
这是错误:
警告 NativeBase:透明上深色文本的 1:1 对比度低于 WCAG 建议的绝对最小对比度 3:1。 https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast InputBase@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:193716:28 RCTView 查看@http://localhost:8081/ index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:150602:25 Box@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly =false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:191721:24 InputAdvance@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native。 example.DanceConnectyCube:193858:33 输入@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:193651:24 RCTView 查看@http //localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:150602:25 Box@http://localhost:8081/index.bundle? platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:191721:24 UserListScreen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app =org.reactjs.native.example.DanceConnectyCube:223372:50 StaticContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube: 234421:17 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:230142:24 SceneView@http://localhost: 8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:234305:22 RCTView视图 RCTView视图背景@http://localhost:8081/index.bundle?platform =ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:236500:21 Screen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app= org.reactjs.native.example.DanceConnectyCube:237782:108 RNSScreen AnimatedComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube: 67782:80 AnimatedComponentWrapper Screen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:238098:36 MaybeScreen@http://localhost :8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:237954:24 RNSScreenContainer ScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev= true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:238211:31 MaybeScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs .native.example.DanceConnectyCube:237923:23 RCTView 查看 SafeAreaProviderCompat@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:237712: 24 BottomTabView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:226059:30 @http://localhost:8081/index .bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:234075:24 BottomTabNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly= false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:225921:32 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example .DanceConnectyCube:230142:24 BaseNavigationContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:229651:28 ThemeProvider@http:// /localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:235690:21 NavigationContainerInner@http://localhost:8081/index.bundle?platform= ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:235550:26 SSRProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org .reactjs.native.example.DanceConnectyCube:193075:25 ToastProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:204142: 24 PortalProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:201313:50 HybridProvider@http://localhost:8081/ index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.DanceConnectyCube:214396:24 RNCSafeAreaProvider …
我是刚开始使用 Strapi。
我创建了一个“事件”集合类型。
我的事件集合类型具有以下字段(请注意图像字段)
当我访问 http://localhost:1337/api/events 时
我得到以下 json,其中不包含图像字段的信息。这是个问题。为什么图像信息不显示?如何让api返回的json中包含图片信息?
{"data":[{"id":1,"attributes":{"name":"Throwback Thursday with DJ Manny Duke","slug":"throwback-thursday-with-dj-manny-duke","venue":"Horizon Club","address":"919 3rd Ave New York, New York(NY), 1002","date":"2022-07-20T02:00:00.000Z","time":"10:00 PM","createdAt":"2022-04-12T02:05:08.246Z","updatedAt":"2022-04-12T02:17:16.760Z","publishedAt":"2022-04-12T02:05:16.192Z","performers":"DJ Manny Duke","description":"Description for the vent of DJ Manny Duke"}},{"id":2,"attributes":{"name":"Boom Dance Festival Experience","slug":"boom-dance-festival-experience","venue":"Blackjacks","address":"123 Lexington","date":"2022-04-25T16:00:00.000Z","time":"8:00 PM","createdAt":"2022-04-12T02:26:32.123Z","updatedAt":"2022-04-12T02:26:33.540Z","publishedAt":"2022-04-12T02:26:33.538Z","performers":"DJ LUKE, DJ BLACKJACK","description":"Whatever Description"}},{"id":3,"attributes":{"name":"Encore Night Boat Party","slug":"encore-night-boat-party","venue":"Encore","address":"12343 New York","date":"2022-11-14T16:00:00.000Z","time":"7:00 PM","createdAt":"2022-04-12T02:28:06.028Z","updatedAt":"2022-04-12T02:28:36.292Z","publishedAt":"2022-04-12T02:28:07.622Z","performers":"BAD BOY BILL","description":"Description of Encore"}}],"meta":{"pagination":{"page":1,"pageSize":25,"pageCount":1,"total":3}}}
Run Code Online (Sandbox Code Playgroud) 我在redux应用程序中使用react-router-dom.
这是我在index.js中的初始设置:
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>
, document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)
然后在我的App.js中我有:
render() {
return (
<div className="App">
<Route exact path="/" render={ () => {
return (
<div>
{
this.props.categories.map((category)=>{
console.log('category', category)
return (
<Link key={category.name} to="/category" >{category.name}</Link>
)
})
}
</div>
)
}}
/>
<Route path="/category" render={ () => {
console.log('category path this.props', this.props)
return (<p>Category is whatever</p>)
}}
/>
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
我认为每当我点击显示的任何链接时,浏览器会自动知道如何呈现新的路径路径/类别,但由于某种原因它不会.
我究竟做错了什么?
我已经下载/安装了一个 node_module(npm 包)......我在 node_modules 文件夹中使用了内部文件以满足我的需求。将它用作 node_module 对我来说是最方便的,但是我担心下次我更新 npm 包时,它可能会更新并删除我所做的所有更改。确保仅不更新特定包的最佳方法是什么?
非常感谢
我在安装 pod 时收到以下错误。
The name of the given podspec `Yoga` doesn't match the expected one `yoga`
Run Code Online (Sandbox Code Playgroud)
在 Podfile 中,这些是唯一带有“yoga”一词的行,并且它们是小写的......所以我不知道是什么导致了这个问题......
pod 'yoga',
:path => "../node_modules/react-native/ReactCommon/yoga",
:inhibit_warnings => true
Run Code Online (Sandbox Code Playgroud)
怎么解决?
我有一个 Expo 应用程序,我正在其中使用 NativeBase 库(https://nativebase.io/)
由于某种原因,应用程序没有针对状态栏进行调整。显示的小部件围绕状态栏区域绘制,而不是通常情况下在状态栏下方开始绘制。
我可以使用 NativeBase 库来调整此 Expo 应用程序中的状态栏高度吗?
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { NativeBaseProvider, Box, Text, VStack, HStack, Checkbox, Divider, Heading, Center, ScrollView, FlatList } from 'native-base';
export default function App() {
var data = [
{
id: "bd7acbea-c1b1-46c2-aed5-3ad53abb28ba",
title: "First Item",
},
{
id: "3ac68afc-c605-48d3-a4f8-fbd91aa97f63",
title: "Second Item",
},
{
id: "58694a0f-3da1-471f-bd96-145571e29d72",
title: "Third Item",
},
]
return (
<NativeBaseProvider> …Run Code Online (Sandbox Code Playgroud) react-native ×3
expo ×2
javascript ×2
native-base ×2
cocoapods ×1
iron-router ×1
meteor ×1
node-modules ×1
npm ×1
npm-install ×1
pod-install ×1
react-redux ×1
reactjs ×1
spacebars ×1
statusbar ×1
strapi ×1
wcag ×1
xcode ×1