我正在使用shopify Polaris的导航组件。它的文档在这里:
https://polaris.shopify.com/components/structure/navigation
假设我在Navigation.js
类中设置了一个导航组件,如下所示:
<Navigation location="/">
<Navigation.Section
items={[
{
url: '/path/to/place',
label: 'Summary',
icon: 'home',
selected:true
},
{
url: '/path/to/place',
label: 'Orders',
icon: 'orders',
badge: ''
},
{
url: '/path/to/place',
label: 'Products',
icon: 'products',
},
]}
/>
</Navigation>
在我上面发送的链接中,它讨论了onClick()方法。如何创建打印所选项目标签的方法。因此,如果他们单击第一项,则将调用回调函数并显示“摘要”。我似乎无法拼凑而成。任何帮助将是巨大的!
答案 0 :(得分:0)
您应将其与#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define MEM_SIZE 1024u
#define LINE_SIZE 128u
#define STR_SIZE 8u
int main(int argc, char *argv[])
{
// Try to open the input file
if (argc < 2) {
fprintf(stderr, "Missing file name in command line.\n");
return EXIT_FAILURE;
}
FILE *memin = fopen(argv[1], "r");
if (memin == NULL) {
fprintf(stderr, "Unable to open file [%s].\n", argv[1]);
return EXIT_FAILURE;
}
// I'd use plain arrays to store the lines
char memory[MEM_SIZE][STR_SIZE + 1] = {{'\0'}};
char line[LINE_SIZE] = {'\0'};
size_t count = 0;
while ( count < MEM_SIZE && fgets(line, LINE_SIZE, memin) ) {
size_t length = strcspn(line, "\r\n");
if (length > STR_SIZE) {
fprintf(stdout, "Warning, line too long: %zu.\n", count);
length = STR_SIZE;
}
memcpy(memory[count], line, length);
memory[count][STR_SIZE] = '\0';
++count;
}
for ( size_t i = 0; i < count; ++i ) {
printf("[%s]\n", memory[i]);
}
}
项一起传递,例如:
Navigation.Section