Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在跳转的时候怎么携带参数呢 #166

Open
condyTao opened this issue May 15, 2024 · 3 comments
Open

在跳转的时候怎么携带参数呢 #166

condyTao opened this issue May 15, 2024 · 3 comments

Comments

@condyTao
Copy link

列如:
{
title: '角色', dataIndex: 'role_ids', width: 120, formType: 'select', multiple: true,
dict: { url: 'system/role/list?role_id=1', props: { label: 'name', value: 'id' } }, hide: true,
commonRules: [{ required: true, message: '角色必选' }],
editDefaultValue: async (record) => {
const response = await admin.read(record.id)
return response.data.roleList.map(item => item.id )
}
},
我想在这个url后面加上一个参数role_id的值

Copy link

dosubot bot commented May 15, 2024

To append an additional parameter to the URL in your dict configuration, you can directly modify the URL string to include your new parameter. Here's a quick way to do it:

dict: {
  url: 'system/role/list?role_id=1&additionalParam=value', // Append your parameter here
  props: { label: 'name', value: 'id' }
},

Just replace additionalParam and value with the actual parameter name and value you want to add. This method allows you to dynamically adjust the URL based on your requirements, making it easy to pass extra data to your endpoint.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@condyTao
Copy link
Author

url: 'system/role/list?role_id=1&additionalParam=value',这里的role_id后面跟的参数需要动态获取 @dosubot

Copy link

dosubot bot commented May 15, 2024

To dynamically append a role_id parameter to your URL in Vue, you can use a computed property or a method that returns the URL with the dynamically included role_id. Here's how you can do it:

  1. Using a Computed Property: Ideal for reactive role_id values that change based on user interactions or other conditions.
import { computed } from 'vue';

const roleId = ref(''); // Your reactive role_id

const dynamicUrl = computed(() => {
  return `system/role/list?role_id=${roleId.value}&additionalParam=value`;
});
  1. Using a Method: Suitable for generating the URL on-demand, such as before making an API call.
import { ref } from 'vue';

const roleId = ref(''); // Set this based on conditions or user selection

function getDynamicUrl() {
  return `system/role/list?role_id=${roleId.value}&additionalParam=value`;
}

Replace additionalParam=value with any other parameters you need to include. Ensure roleId is updated based on your application's logic, and use the dynamic URL where needed in your component or API calls.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant