graph-layout 相关问题


Microsoft Graph API - 用户和组的每个增量查询的页面大小是多少?

每个增量查询的页面大小是多少? https://developer.microsoft.com/en-us/graph/docs/concepts/delta_query_users https://developer.microsoft.com/en-us/graph/docs/concepts/delta_query_group...


如何将yield return与microsoft graph api v5 PageIterator一起使用

目前我正在使用 AsyncEnumerable 从 Graph API 获取组成员 公共异步 IAsyncEnumerable LoadGroupMembers(string GroupId) { if (graphClient == null) th...


Microsoft Graph 5.38 获取文件内容失败

我已将我们的项目更新到.Net 7,这要求我将 Microsoft Graph API 版本更新到版本 5.38。在大多数情况下,一切都运行良好,除了


查找 Microsoft Graph 范围

由于 Graph 是一种自记录语言,因此我想利用这一点并编写 PowerShell 函数来根据元数据自动生成 cmdlet。我已经有很多这样的完整的了,...


如何模拟Microsoft Graph API SDK客户端?

我在项目中使用了Microsoft Graph SDK来调用图形API,为此我需要使用GraphServiceClient。 要使用 GraphServiceClient,我必须添加一些辅助类,其中 SDKHelper 是一个...


按类别过滤 Microsoft Graph API 中的日历视图请求

我需要从 Graph API 事件中获取没有任何类别或没有特定类别的事件 所以,当我发送: https://graph.microsoft.com/v1.0/me/calendarView?startDateTime=2024-01-05T12:32:50.095Z&endDat...


如何让 Azure Graph Explorer 返回 subscriptionId 的 GUID 值,而不是将其转换为名称?

我正在导出 Azure 资源列表(假设是 VM)及其相应的 SubscriptionId(GUID)。 尝试通过 Graph Explorer 执行此操作似乎正在翻译并且


使用curl发出MS Graph请求

我正在尝试使用 Perl/curl 做一些 MS Graph 工作,但遇到了一些问题。把问题带回到我能想到的最基本的例子:来自bash脚本的2个curl命令。 我有一个


为什么 Microsoft Graph API 列出消息时无法获取响应的 body 字段?

我想阅读某些电子邮件并过滤它们。我正在使用 Microsoft Graph API 查询 Office 365 邮箱,如下所示。我还添加了 API 权限“Mail.ReadBasic.All”以获得


如何使用 Microsoft Graph API 解决 Sharepoint(FileContentRead) 中的 404 -“ItemNotFound”错误?

我使用下面的 API 使用 Microsoft Graph API 从 Sharepoint 读取其内容。 https://graph.microsoft.com/v1.0/sites/{主机名},{spsite-id},{spweb-id}/drives//items/ 我使用下面的 API 使用 Microsoft Graph API 从 Sharepoint 读取其内容。 https://graph.microsoft.com/v1.0/sites/{hostname},{spsite-id},{spweb-id}/drives/<drive-id>/items/<items-id>/content 两天前,它正确地从根站点正确获取文件内容。但今天我检查了是否获得了与以下问题相同的文件内容。 { "error": { "code": "itemNotFound", "message": "Item not found", "innerError": { "request-id": "<request_id>", "date": "<date_time>" } } } 不知道这可能是什么原因造成的?我在谷歌上搜索没有找到更好的解决方案。 有人建议我解决上述问题的方法。 我建议使用此端点下载流式 DriveItem 内容: GET /sites/{siteId}/drive/items/{item-id}/content https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http


使用 Microsoft Graph 获取所有电子邮件 - 版本 5.2.0 或更高版本

我的原始代码是: var messages = wait graphClient.Users["[email protected]"].MailFolders[folderName].Messages.GetAsync(); 我正在使用 Microsoft.Graph 5.2.0。 不幸的是...


复杂的 Microsoft Graph API 查询,可能吗?

假设我想查询属于 A 组成员的 microsoft.graph.group 列表,并且我想在结果集中包含 microsoft.graph.user 类型的那些组的成员,但是...


下载 GraalVM 理想图形可视化工具

我经历了从 https://www.graalvm.org/latest/tools/igv/ 设置 Ideal Graph Visualizer 的过程,并且我能够下载 mx 和 graal 存储库,但是当我尝试启动 . ..


将 EdgeList 作为 unordered_set 存储在 Boost Graph Library 上

我正在重现一个科学实验,我需要将图的边集存储为无序集。我正在尝试使用 BGL adjacency_graph,我认为最后一个参数是 hash_...


为什么NLog不每天归档

NLog 存档每天都不起作用。但它每分钟都有效 NLog版本5.0.7 这是我的配置 NLog 每天存档不起作用。但它每分钟都有效 NLog版本5.0.7 这是我的配置 <target name="Httpfile" layout="${longdate} ${uppercase:${level}} correlationId-${activityid} - ${message} ${exception:format=tostring}" xsi:type="File" fileName="${logFullName}-http-api-${shortdate}.log" archiveFileName="${logFullNameArchive}-archive-Http-api-${shortdate}-{#####}.zip" archiveEvery="Day" concurrentWrites="true" keepFileOpen="false" archiveNumbering="DateAndSequence" maxArchiveFiles="30" maxArchiveDays="7" enableArchiveFileCompression="true" /> 使用 archiveEvery="Minute" 效果很好 不支持在NLog FileTarget中混合静态和动态归档逻辑。 使用静态归档逻辑时,不应在 ${shortdate} 和 fileName="..." 中使用 archiveFileName="..."。 像enableArchiveFileCompression="true"这样的一些功能仅受静态归档逻辑支持: <target name="Httpfile" layout="${longdate} ${uppercase:${level}} correlationId-${activityid} - ${message} ${exception:format=tostring}" xsi:type="File" fileName="${logFullName}-http-api.log" archiveFileName="${logFullNameArchive}-archive-Http-api-{#####}.zip" archiveNumbering="DateAndSequence" archiveDateFormat="yyyyMMdd" archiveEvery="Day" concurrentWrites="true" keepFileOpen="false" maxArchiveFiles="30" maxArchiveDays="7" enableArchiveFileCompression="true" /> 另请参阅:https://github.com/NLog/NLog/wiki/FileTarget-Archive-Examples


Graph Api 多重过滤以获取最近 30 天上次登录的用户

我正在尝试使用图形 API 构建一个请求,以获取过去 30 天内未登录的所有用户。和: $URL =“https://graph.microsoft.com/v1.0/users?`$filter=signInActivity/lastSignInDateT...


将 props 传递给 nextjs 中的页面组件

我正在使用 nextjs 的 withlayout 函数为某些页面添加侧边栏。 导出类型 PageWithLayout = NextPage & { withLayout?:(页面:ReactElement)=> 我正在使用 nextjs 的 withlayout 函数为某些页面添加侧边栏。 export type PageWithLayout<P = {}, IP = P> = NextPage<P, IP> & { withLayout?: (page: ReactElement) => ReactNode; }; 这是我的使用方法: export const Interactions: PageWithLayout = () => { const [ getInteractions, { data: interactionData, fetchMore, variables, loading: isInteractionsLoading, error: isInteractionsError, }, ] = useGetInteractionsLazyQuery({ notifyOnNetworkStatusChange: true, fetchPolicy: "network-only", ssr: false, }); return ( <> <Box height={"100vh"}> </Box> </> ); }; Interactions.withLayout = (page: ReactElement) => { // how do I pass isInteractionsLoading as a prop to this component return <Layout>{page}</Layout>; }; export default Interactions; 我想要实现的是将 isInteractionsLoaded 和 isInteractionsError 作为属性传递给我的布局组件,以便我可以渲染这些状态。有没有一种方法可以实现此目的,而无需将布局组件移动到页面组件内? 创建一个包装组件的 React Context 提供程序可能是您使用的解决方案,如果您不想使用任何其他包或不想使用 redux 等更强大的工具,则可以使用。 但是在这里使用有点尴尬,具体取决于包含交互的组件树是什么样子。否则可以根据您的需要使用 _app 入口点。 示例上下文和用法 import React from 'react'; export const InteractionContext = React.createContext({ isInteractionsLoading: false, isInteractionsError: null, }); // parent component or _app if necessary const ProviderComponent = () => { return ( <InteractionContext.Provider value={{ isInteractionsLoading, isInteractionsError }}> <Interactions /> </InteractionContext.Provider> ); }; const Layout = ({ children }) => { const { isInteractionsLoading, isInteractionsError } = useContext(InteractionContext); // Now you can use isInteractionsLoading and isInteractionsError here // ... return <div>{children}</div>; };


如何从 SPFx 中选定的文档中获取文档 ID?

我有一个包含文档和 SP listView 扩展的文件夹。我希望能够在选择文件夹中的文档后检索文档 ID,以便使用它们执行 Graph API 请求...


我使用fviz_eig并尝试更改字体大小和百分比标签的类型,但出现一些错误

我使用 fviz_eig 使用以下代码生成具有自定义尺寸和标签字体类型的解释方差图: 压力.m_pca <- PCA(stress.m, scale.unit = TRUE, ncp = 8, graph = ...


NextJS 为 opengraph 标签动态创建图像,但在生产中不起作用

我正在开发一个 Next.js 项目,我需要动态生成 Open Graph 图像。我的实现可以在本地运行,但在 Vercel 和 Netlify 上部署到生产环境时遇到问题。 L...


使用 microsoft graph api rest 设置共享点驱动器项目的查找字段值

在 Sharepoint online 上,我有一个包含文件的文档库和一个包含一些元数据的列表,我想将其链接到文件。由于您无法使用文档库项目的查找字段,但...


无法解析 Microsoft graph 的 url 字符串,因为使用 Invoke-MSGraphRequest 命令和查询参数

我无法使用当前 URL 进行解析和调用,因为当我使用 $filter 和 $select 查询参数时,它会破坏字符串,但它在 Postman 中工作得很好,并为我提供了我需要的所有数据。


作为具有委派管理员权限的合作伙伴,以非交互方式向应用程序授予管理员同意

我想通过 Microsoft Graph API(客户端凭据流)从多个客户租户获取数据。 因此,我在我的租户中注册了一个多租户应用程序。 目前,我必须给出缺点......


如何将 XAML(或另一个 ContentView)作为子项传递给 ContentView

我正在尝试创建一个 ContentView,并在其中将子项作为 XAML 或(另一个内容视图)传递。我怎样才能做到这一点? 例如。: 我有一种观点说 Header.xaml 我正在尝试创建一个 ContentView,并在其中将子项作为 XAML 或(另一个内容视图)传递。我怎样才能做到这一点? 例如: 我有一种观点是 Header.xaml <?xml version="1.0" encoding="utf-8" ?> <ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:strings="clr-namespace:Eurynote.Localization.Resources.en;assembly=Eurynote.Localization" x:Class="Eurynote.Core.Views.Common.EurynoteHeader"> <HorizontalStackLayout Spacing="10" VerticalOptions="Center"> <Image Source="brand_icon" WidthRequest="32" HeightRequest="30" /> <Label Text="Header" Margin="0,-3,0,0" /> </HorizontalStackLayout> </ContentView> 现在,在我的 MainPage.xaml 文件中,我可以将此视图称为 <common:Header /> 并且运行良好。 但是我如何将另一个控件传递到与子项相同的内容视图,例如按钮、标签等...或任何其他 ContentView,如下面两个示例所示。 <common:Header> <Button Text="Button" /> </common:Header> <common:Header> <common:AnotherView /> </common:Header> 我想确保只能传递单个内容,如Frame。 谢谢你!!! 首先,如果使用以下代码,ContentView的内容将被Button覆盖。 <common:Header> <Button Text="Button" /> </common:Header> 因此您无法从 xaml 中为 contentview 添加子项。但你可以在后面的代码中做到这一点。如: 在xaml中: <common:Header x:Name = "header"> 在页面的构造函数中: public partial class MainPage() { InitializeComponent(); var layout = head.Content as HorizontalStackLayout; layout.Children.Add(new Button(){ Text = "new button"}); } 您可以通过这种方式将新项目作为子项添加到内容视图中。


TextInput 在小屏幕手机上显示太窄

在以下 xml 中,“message_entry”在小屏幕 (240 x 320) 上显示太窄,但在较大屏幕 (480 x 640) 上显示良好。 在以下 xml 中,“message_entry”在小屏幕 (240 x 320) 上显示太窄,但在较大屏幕 (480 x 640) 上显示良好。 <androidx.cardview.widget.CardView android:id="@+id/reply_bar_card" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardBackgroundColor="@color/replyBarCard" app:cardCornerRadius="24dp" app:cardElevation="5dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingBottom="24dp"> <ProgressBar android:id="@+id/send_progress" style="@style/Widget.AppCompat.ProgressBar.Horizontal" android:layout_width="match_parent" android:layout_height="3dp" android:indeterminate="true" android:visibility="invisible" /> <HorizontalScrollView android:id="@+id/attached_image_scroller" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/message_list_padding" android:layout_marginEnd="@dimen/message_list_padding" android:paddingTop="8dp" android:paddingBottom="8dp" android:scrollbars="none" android:visibility="gone"> <LinearLayout android:id="@+id/attached_image_holder" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="12dp" android:layout_marginEnd="12dp" android:orientation="horizontal" /> </HorizontalScrollView> <LinearLayout android:id="@+id/smart_reply_container" android:layout_width="match_parent" android:layout_height="56dp" android:layout_marginStart="@dimen/message_list_padding" android:layout_marginEnd="@dimen/message_list_padding" android:gravity="end" android:orientation="horizontal" android:visibility="gone"> <ImageButton android:id="@+id/close_smart_replies" android:layout_width="32dp" android:layout_height="48dp" android:layout_gravity="center_vertical" android:layout_marginStart="8dp" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/use_smart_replies" android:src="@drawable/ic_cancel" android:tint="@color/secondaryText" /> <LinearLayout android:id="@+id/smart_reply_suggestions_container" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginEnd="12dp" android:layout_weight="1" android:gravity="end" android:orientation="horizontal" /> </LinearLayout> <LinearLayout android:id="@+id/send_bar" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginStart="@dimen/message_list_padding" android:layout_marginEnd="@dimen/message_list_padding" android:alpha="0" android:clipToPadding="false" android:gravity="center_vertical|start" android:orientation="horizontal" android:padding="8dp" android:translationY="-32dp"> <ImageButton android:id="@+id/select_sim" android:layout_width="32dp" android:layout_height="48dp" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/select_sim" android:src="@drawable/ic_sim" android:tint="@color/secondaryText" android:visibility="gone" /> <ImageButton android:id="@+id/view_scheduled_messages" android:layout_width="32dp" android:layout_height="match_parent" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/view_scheduled_messages" android:src="@drawable/ic_schedule_small" android:tint="@color/secondaryText" android:visibility="gone" /> <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginEnd="8dp"> <ImageButton android:id="@+id/attach" android:layout_width="32dp" android:layout_height="48dp" android:layout_gravity="center_vertical|start" android:background="?selectableItemBackgroundBorderless" android:clickable="true" android:contentDescription="@string/attach" android:src="@drawable/ic_attach" android:tint="@color/secondaryText" /> <TextView android:id="@+id/text_counter" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:layout_marginBottom="2dp" android:gravity="center_horizontal" android:textColor="@color/secondaryText" android:textSize="12sp" /> </FrameLayout> <com.google.android.material.textfield.TextInputEditText android:id="@+id/message_entry" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@null" android:backgroundTint="@color/drawerBackground" android:hint="@string/type_message_to" android:imeOptions="actionSend|flagNoExtractUi" android:inputType="textCapSentences|textAutoCorrect|textMultiLine" android:maxLines="@integer/message_list_fragment_line_entry_count" android:minHeight="40dp" android:padding="8dp" android:paddingStart="8dp" android:paddingEnd="18dp" android:scrollHorizontally="false" android:textSize="16sp" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:contentDescription="@string/send_message" android:src="@drawable/ic_send" app:elevation="0dp" app:fabSize="mini" app:rippleColor="@android:color/white" /> </LinearLayout> <ViewStub android:id="@+id/attach_stub" android:layout_width="match_parent" android:layout_height="@dimen/attach_menu_height" android:layout="@layout/view_attach_menu" /> </LinearLayout> </androidx.cardview.widget.CardView> 小屏幕:(添加红框用于说明) 大屏幕:(添加红框作为说明) 预期的行为就像大屏幕,其中“message_entry”尽可能宽。为什么“message_entry”在小屏幕上那么窄?我该如何解决它? 原来是因为dimens.xml文件夹下有多个res文件造成的。这用于支持多种屏幕尺寸,在较小屏幕的 dimens.xml 中,有 <dimen name="message_list_padding">96dp</dimen>。一旦更改为0dp,布局就如预期的那样。 有关多个 dimens.xml 文件的更多信息,请参阅此答案中的#2。


.NET MAUI、ios UseSafeArea 不工作 StackLayout、VerticalStackLayout 和 Grid

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Test.Views.Activities.ActivityMapList" xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps" xmlns:sensors="clr-namespace:Microsoft.Maui.Devices.Sensors;assembly=Microsoft.Maui.Essentials" xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls" ios:Page.UseSafeArea="False" Shell.NavBarIsVisible="False" Style="{StaticResource Key=DefaultPage}"> <ContentPage.Content> <StackLayout> <maps:Map VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <x:Arguments> <MapSpan> <x:Arguments> <sensors:Location> <x:Arguments> <x:Double>36.9628066</x:Double> <x:Double>-122.0194722</x:Double> </x:Arguments> </sensors:Location> <x:Double>0.01</x:Double> <x:Double>0.01</x:Double> </x:Arguments> </MapSpan> </x:Arguments> </maps:Map> </StackLayout> </ContentPage.Content> </ContentPage> StackLayout 或 Grid 内的地图控件,iOS 的 SafeArea 为 false,如图所示。 你有什么解决办法吗? 我需要在地图上使用网格或堆栈布局 默认情况下.NET MAUI 将考虑安全区域。所以使用特定于平台的UseSafeArea就是禁用安全区域。目前,将 UseSafeArea 设置为 false 不会改变行为(尽管应该如此),这是一个错误。另请参阅 MAUI github 上的问题:https://github.com/dotnet/maui/issues/5856 您还可以设置 IgnoreSafeArea 属性来实现相同的目的。但是,它不再在 .NET 7 中工作,请参阅以下问题:https://github.com/dotnet/maui/issues/12823 要解决您的问题,您需要将 IgnoreSafeArea="True" 添加到您的 Grid 或 StackLayout 并将 ios:Page.UseSafeArea="False" 添加到您的页面。这应该不是必需的,但这是对我有用的解决方法。 有关在 iOS 上禁用安全区域的文档可以在此处找到:https://learn.microsoft.com/en-us/dotnet/maui/ios/platform-specifics/page-safe-area-layout?view=net-毛伊岛-7.0 您可以设置 Page Padding 值来实现。在OnAppearing方法中,设置页面的safeInsets,如下代码: protected override void OnAppearing() { base.OnAppearing(); DeviceSafeInsetsService d = new DeviceSafeInsetsService(); double topArea = d.GetSafeAreaTop(); double bottomArea = d.GetSafeAreaBottom(); var safeInsets = On<iOS>().SafeAreaInsets(); safeInsets.Top = -topArea; safeInsets.Bottom = -bottomArea; Padding = safeInsets; } 要获取 topArea 和 bottomArea 值,您应该编写平台代码。答案末尾附有有关此内容的更详细教程。 首先你可以在Project文件夹中生成一个新的类文件并将其更改为部分类。生成两个部分方法。 public partial class DeviceSafeInsetsService { public partial double GetSafeAreaTop(); public partial double GetSafeAreaBottom(); } 然后在iOS平台生成部分文件并实现。该文件位于 Project/Platform/iOS 文件夹中,我想提一下的是,该文件是一个部分文件,因此命名空间应与上面的文件相同。生成此文件时,请删除命名空间中的 .Platforms.iOS 后缀。 public partial class DeviceSafeInsetsService { public partial double GetSafeAreaBottom() { if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow(); var bottomPadding = window.SafeAreaInsets.Bottom; return bottomPadding; } return 0; } public partial double GetSafeAreaTop() { if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow(); var TopPadding = window.SafeAreaInsets.Top; return TopPadding; } return 0; } } 更多信息,您可以参考如何在.NET MAUI中编写特定于平台的代码和MauiPlatformCode示例代码 希望它对你有用。


在 Rails 5 中单击浏览器上的后退按钮时,带有 Select2 的表单会重复

_header.html.erb(用于表单部分) <%= form_for home_path, class: 'home', role: 'search', method: :get do |f| %> _header.html.erb(用于表单部分) <%= form_for home_path, class: 'home', role: 'search', method: :get do |f| %> <div class="form-group" style="display:inline;"> <div class="input-group input-group-md"> <%= text_field_tag :q, params[:q], placeholder: ... ,class: 'form-control hideOverflow', type: "search" %> <%= select_tag "category", options_from_collection_for_select(...),include_blank: true, class: 'form-control hideOverflow', type: "search" %> <%if logged_in? %> <%= select_tag "location", options_for_select([...], ...),class: 'form-control hideOverflow', type: "search" %> <% else %> <%= select_tag "location", options_for_select([...], ...),class: 'form-control hideOverflow', include_blank: true, type: "search" %> <% end %> <span class="input-group-addon"><%= submit_tag "Search", class: "btn-transparent"%></span> </div> </div> <% end %> JS代码 <script> $( document ).on('turbolinks:load', function() { $('select#category').select2({ width: '60%', dropdownAutoWidth : true, placeholder: "Choose a category", maximumSelectionLength: 3 }); $('select#location').select2({ width: '40%', dropdownAutoWidth : true, minimumResultsForSearch: Infinity }); }); </script> 故障或渲染问题(单击链接查看图像) 有人可以帮我解决为什么吗?另外,我的搜索表单位于标题部分文件的导航栏中。 如果我去掉脚本中的 $(...).select ,一切都会正常...我认为 select.js 有问题 在此回复: https://stackoverflow.com/a/41915129/5758027 我在自己的代码中使用了这个解决方案: $(document).on('turbolinks:before-cache', function() { // this approach corrects the select 2 to be duplicated when clicking the back button. $('.select-select2').select2('destroy'); $('.select-search-select2').select2('destroy'); } ); 和观察者: $(document).ready( ready ); //... once document ready $(document).ajaxComplete( ready ); //... once ajax is complete $(document).on('turbolinks:load', ready ); //... once a link is clicked function ready() { $(".select-search-select2").select2({ theme: "bootstrap", language: 'es', allowClear: true }); $(".select-select2").select2({ theme: "bootstrap", language: 'es', minimumResultsForSearch: Infinity, allowClear: true }); }; 总是清除缓存不是会让使用 Turbolink 变得毫无意义吗? 不如这样? $(document).on('turbolinks:before-cache', function(e) { return $('.form-control.select2').each(function() { return $(this).select2('destroy'); }); }); 我无法解决这个渲染问题(仍在等待正确的答案!),但如果有人像我一样遇到类似的问题,请尝试跳出框框思考。这是我的技巧:我在应用程序中添加了一个后退按钮。 获取完整的url路径 # get the previous url def save_previous_page session[:return_to] = request.fullpath end 仅当页面不是主页或搜索页面时才显示后退按钮 <% if session[:return_to] != request.fullpath%> <%= link_to session.delete(:return_to) || request.fullpath, class: 'back-button' do%> <i class="fa fa-arrow-circle-left" aria-hidden="true"></i> <%end%> <% end %> 同时,我仍在等待并尝试解决渲染问题... 解决了问题 只需将此代码添加到您的 .js 文件中 Turbolinks.clearCache(); 这很可能是一些资源不一致,您应该检查您的 app\views\layouts 文件夹中是否有重复声明 wither jQuery、jQuery UJS 或 Turbolinks 的文件。检查页面的所有 <script> 标签,以及是否在 layout 文件夹和内部视图中声明相同的脚本。如果情况并非如此,请检查是否有 render、yield 或 build 呼叫 简单的解决方案,不要在您不希望它运行的东西上运行 select2 构建器。 $("select#category:not(.select2-container):not(.select2-hidden-accessible)").select2(); Rails 7 更新 这里的很多东西在 Rails 7 中都不起作用,尤其是 turbolinks:before-cache 事件。您正在寻找的新事件是 turbo:before-cache 和 turbo:load,所以它看起来像这样: $(document).on("turbo:before-cache", function() { $("#select_id").select2('destroy'); }); $(document).on('turbo:load', function() { $('#select_id').select2(); });


© www.soinside.com 2019 - 2024. All rights reserved.